[libvirt] [libvirt-designer][PATCH v2 4/4] domain: Introduce interface support
Michal Privoznik
mprivozn at redhat.com
Mon Sep 10 17:33:56 UTC 2012
On 10.09.2012 19:03, Martin Kletzander wrote:
> On 09/10/2012 03:58 PM, Michal Privoznik wrote:
>> Let users add NICs to domains.
>> ---
>> examples/virtxml.c | 78 ++++++++++++++++++++++++++
>> libvirt-designer/libvirt-designer-domain.c | 83 ++++++++++++++++++++++++++++
>> libvirt-designer/libvirt-designer-domain.h | 3 +
>> libvirt-designer/libvirt-designer.sym | 1 +
>> 4 files changed, 165 insertions(+), 0 deletions(-)
>>
>> diff --git a/examples/virtxml.c b/examples/virtxml.c
>> index 20e3f3c..df83f57 100644
>> --- a/examples/virtxml.c
>> +++ b/examples/virtxml.c
>> @@ -35,6 +35,7 @@
>> #include <unistd.h>
>>
>> GList *disk_str_list = NULL;
>> +GList *iface_str_list = NULL;
>>
>> #define print_error(...) \
>> print_error_impl(__FUNCTION__, __LINE__, __VA_ARGS__)
>> @@ -215,6 +216,79 @@ add_disk_str(const gchar *option_name,
>> return TRUE;
>> }
>>
>> +static void
>> +add_iface(gpointer data,
>> + gpointer user_data)
>> +{
>> + GVirDesignerDomain *domain = (GVirDesignerDomain *) user_data;
>> + char *network = (char *) data;
>> + char *param = NULL;
>> + GVirConfigDomainInterface *iface = NULL;
>> + GError *error = NULL;
>> +
>> + param = strchr(network, ',');
>> + if (param) {
>> + *param = '\0';
>> + param++;
>> + }
>> +
>> + iface = gvir_designer_domain_add_interface_network(domain, network, &error);
>> + if (error) {
>> + print_error("%s", error->message);
>> + exit(EXIT_FAILURE);
>> + }
>> +
>> + while (param && *param) {
>> + char *key = param;
>> + char *val;
>> + GVirConfigDomainInterfaceLinkState link;
>> +
>> + /* move to next token */
>> + param = strchr(param, ',');
>> + if (param) {
>> + *param = '\0';
>> + param++;
>> + }
>> +
>> + /* parse token */
>> + val = strchr(key, '=');
>> + if (!val) {
>> + print_error("Invalid format: %s", key);
>> + exit(EXIT_FAILURE);
>> + }
>> +
>> + *val = '\0';
>> + val++;
>> +
>> + if (!strcmp(key, "mac")) {
>> + gvir_config_domain_interface_set_mac(iface, val);
>> + } else if (!strcmp(key, "link")) {
>> + if (!strcmp(val, "up")) {
>> + link = GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_UP;
>> + } else if (!strcmp(val, "down")) {
>
> Change those 4 !strcmp to g_str_equal.
>
> [...]
>
> ACK with that fixed.
>
> Martin
Thanks for review. I've fixed all the nits and pushed whole set.
Michal
More information about the libvir-list
mailing list