[PATCH 0 of 3] Allow users to specify NIC model type

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1240250416 25200 # Node ID bca16d22da253f390a74fb08d4f61f7419308dba # Parent 146ed7d63fbbc2edc78660ddc6ecc393ee61739c Add support for parsing and generating XML for the NIC model type tag Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 146ed7d63fbb -r bca16d22da25 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Thu Apr 16 11:20:21 2009 -0700 +++ b/libxkutil/device_parsing.c Mon Apr 20 11:00:16 2009 -0700 @@ -66,6 +66,7 @@ free(dev->type); free(dev->mac); free(dev->source); + free(dev->model); } static void cleanup_emu_device(struct emu_device *dev) @@ -311,6 +312,10 @@ if (ndev->source != NULL) continue; goto err; + } else if (XSTREQ(child->name, "model")) { + ndev->model = get_attr_value(child, "type"); + if (ndev->model == NULL) + goto err; } } diff -r 146ed7d63fbb -r bca16d22da25 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Thu Apr 16 11:20:21 2009 -0700 +++ b/libxkutil/device_parsing.h Mon Apr 20 11:00:16 2009 -0700 @@ -45,6 +45,7 @@ char *type; char *mac; char *source; + char *model; }; struct mem_device { diff -r 146ed7d63fbb -r bca16d22da25 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Thu Apr 16 11:20:21 2009 -0700 +++ b/libxkutil/xmlgen.c Mon Apr 20 11:00:16 2009 -0700 @@ -210,6 +210,13 @@ return XML_ERROR; xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + if (net->model != NULL) { + tmp = xmlNewChild(nic, NULL, BAD_CAST "model", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST net->model); + } + if (STREQ(dev->dev.net.type, "network")) msg = set_net_source(nic, net, "network"); else if (STREQ(dev->dev.net.type, "bridge"))

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1240250416 25200 # Node ID 7456dabe495895b047b9308c38506cbba1fc0507 # Parent bca16d22da253f390a74fb08d4f61f7419308dba Add support for specifying the NIC model type libvirt only supports this for KVM guests currently. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r bca16d22da25 -r 7456dabe4958 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Apr 20 11:00:16 2009 -0700 +++ b/src/Virt_RASD.c Mon Apr 20 11:00:16 2009 -0700 @@ -398,6 +398,12 @@ "Address", (CMPIValue *)dev->dev.net.mac, CMPI_chars); + + if (dev->dev.net.model != NULL) + CMSetProperty(inst, + "ResourceSubType", + (CMPIValue *)dev->dev.net.model, + CMPI_chars); } else if (dev->type == CIM_RES_TYPE_MEM) { const char *units = "KiloBytes"; diff -r bca16d22da25 -r 7456dabe4958 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Apr 20 11:00:16 2009 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon Apr 20 11:00:16 2009 -0700 @@ -495,6 +495,12 @@ free(dev->dev.net.source); dev->dev.net.source = name_from_pool_id(val); + free(dev->dev.net.model); + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) + dev->dev.net.model = NULL; + else + dev->dev.net.model = strdup(val); + out: return msg; }

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1240250572 25200 # Node ID e5000891e231e6b9896786e48442ef98bfe9f9fd # Parent 7456dabe495895b047b9308c38506cbba1fc0507 Expose NetRASD templates with interface model specified. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 7456dabe4958 -r e5000891e231 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Apr 20 11:00:16 2009 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Apr 20 11:02:52 2009 -0700 @@ -524,6 +524,34 @@ return ret; } +static CMPIStatus set_net_props(int type, + const CMPIObjectPath *ref, + const char *id, + uint64_t num_nics, + const char *model, + struct inst_list *list) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_NET); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + + CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); + CMSetProperty(inst, "VirtualQuantity", + (CMPIValue *)&num_nics, CMPI_uint64); + + if (model != NULL) + CMSetProperty(inst, "ResourceSubType", + (CMPIValue *)model, CMPI_chars); + + inst_list_add(list, inst); + + out: + return s; +} + static CMPIStatus net_template(const CMPIObjectPath *ref, int template_type, struct inst_list *list) @@ -531,7 +559,6 @@ bool ret; uint64_t num_nics; const char *id; - CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; switch (template_type) { @@ -560,15 +587,12 @@ goto out; } - inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_NET); - if ((inst == NULL) || (s.rc != CMPI_RC_OK)) + + s = set_net_props(template_type, ref, id, num_nics, "e1000", list); + if (s.rc != CMPI_RC_OK) goto out; - - CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); - CMSetProperty(inst, "VirtualQuantity", - (CMPIValue *)&num_nics, CMPI_uint64); - - inst_list_add(list, inst); + + s = set_net_props(template_type, ref, id, num_nics, NULL, list); out: return s;

+1 Kaitlin Rupert wrote:
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Richard Maciel, MSc IBM Linux Technology Center rmaciel@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel