[PATCH 0 of 3] Add support for setting nic target device

Per the libvirt documentation, users can specify a network interface's target device. If one isn't provided, libvirt will set one automatically. So this is optional setting. Also per the documentation, a target device name cannot start with 'vnet' or 'vif'. These values are reserved. A corresponding test case is also being submitted.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 9532502f5d5e76efa998c4b6c9339cf47f91b914 # Parent b57ba34c0932d77e11f65282dec5c2094d6ba818 Add new device field to net device struct This field will be used to hold the target device of the network interface device. This patch also includes support for parsing a guest XML to get an already defined target device, as well as code for generating XML with a target device specified. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/device_parsing.c Thu Jan 28 15:45:31 2010 -0800 @@ -64,6 +64,7 @@ free(dev->mac); free(dev->source); free(dev->model); + free(dev->device); } 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, "target")) { + ndev->device = get_attr_value(child, "dev"); + if (ndev->device == NULL) + goto err; } else if (XSTREQ(child->name, "model")) { ndev->model = get_attr_value(child, "type"); if (ndev->model == NULL) @@ -660,6 +665,7 @@ DUP_FIELD(dev, _dev, dev.net.type); DUP_FIELD(dev, _dev, dev.net.source); DUP_FIELD(dev, _dev, dev.net.model); + DUP_FIELD(dev, _dev, dev.net.device); } else if (dev->type == CIM_RES_TYPE_DISK) { DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/device_parsing.h Thu Jan 28 15:45:31 2010 -0800 @@ -50,6 +50,7 @@ char *mac; char *source; char *model; + char *device; }; struct mem_device { diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/xmlgen.c Thu Jan 28 15:45:31 2010 -0800 @@ -217,6 +217,14 @@ return XML_ERROR; xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + if (net->device != NULL) { + tmp = xmlNewChild(nic, NULL, BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST net->device); + } + + if (net->model != NULL) { tmp = xmlNewChild(nic, NULL, BAD_CAST "model", NULL); if (tmp == NULL)

+1 Sharad Mishra System x Enablement Linux Technology Center IBM Kaitlin Rupert <kaitlin@linux.vn et.ibm.com> To Sent by: libvirt-cim@redhat.com libvirt-cim-bounc cc es@redhat.com Subject [Libvirt-cim] [PATCH 1 of 3] Add 01/28/2010 03:58 new device field to net device PM struct Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redh at.com> # HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 9532502f5d5e76efa998c4b6c9339cf47f91b914 # Parent b57ba34c0932d77e11f65282dec5c2094d6ba818 Add new device field to net device struct This field will be used to hold the target device of the network interface device. This patch also includes support for parsing a guest XML to get an already defined target device, as well as code for generating XML with a target device specified. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/device_parsing.c Thu Jan 28 15:45:31 2010 -0800 @@ -64,6 +64,7 @@ free(dev->mac); free(dev->source); free(dev->model); + free(dev->device); } 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, "target")) { + ndev->device = get_attr_value(child, "dev"); + if (ndev->device == NULL) + goto err; } else if (XSTREQ(child->name, "model")) { ndev->model = get_attr_value(child, "type"); if (ndev->model == NULL) @@ -660,6 +665,7 @@ DUP_FIELD(dev, _dev, dev.net.type); DUP_FIELD(dev, _dev, dev.net.source); DUP_FIELD(dev, _dev, dev.net.model); + DUP_FIELD(dev, _dev, dev.net.device); } else if (dev->type == CIM_RES_TYPE_DISK) { DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/device_parsing.h Thu Jan 28 15:45:31 2010 -0800 @@ -50,6 +50,7 @@ char *mac; char *source; char *model; + char *device; }; struct mem_device { diff -r b57ba34c0932 -r 9532502f5d5e libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Wed Jan 13 12:45:15 2010 -0800 +++ b/libxkutil/xmlgen.c Thu Jan 28 15:45:31 2010 -0800 @@ -217,6 +217,14 @@ return XML_ERROR; xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + if (net->device != NULL) { + tmp = xmlNewChild(nic, NULL, BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST net-> device); + } + + if (net->model != NULL) { tmp = xmlNewChild(nic, NULL, BAD_CAST "model", NULL); if (tmp == NULL) _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 0273f86ebd7b6e54ec606d0a2a9aa54ce40246f1 # Parent 9532502f5d5e76efa998c4b6c9339cf47f91b914 Add new attribute to hold the name of the net target device VirtualDevice is used, as this is the same attribute used to hold the target device of a disk device. This patch also adds support for representing the target device in the device's RASD. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 9532502f5d5e -r 0273f86ebd7b schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Thu Jan 28 15:45:31 2010 -0800 +++ b/schema/ResourceAllocationSettingData.mof Thu Jan 28 15:45:31 2010 -0800 @@ -60,6 +60,8 @@ [Description ("Bridge name")] string NetworkName; + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("KVM virtual network configuration"), @@ -74,6 +76,8 @@ [Description ("Bridge name")] string NetworkName; + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("LXC virtual network configuration"), @@ -81,6 +85,8 @@ ] class LXC_NetResourceAllocationSettingData : LXC_ResourceAllocationSettingData { + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("Xen virtual processor"), diff -r 9532502f5d5e -r 0273f86ebd7b src/Virt_RASD.c --- a/src/Virt_RASD.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_RASD.c Thu Jan 28 15:45:31 2010 -0800 @@ -278,6 +278,45 @@ return s; } +static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, + "NetworkType", + (CMPIValue *)dev->dev.net.type, + CMPI_chars); + + CMSetProperty(inst, + "Address", + (CMPIValue *)dev->dev.net.mac, + CMPI_chars); + + if ((dev->dev.net.source != NULL) && + (STREQ(dev->dev.net.type, "bridge"))) + CMSetProperty(inst, + "NetworkName", + (CMPIValue *)dev->dev.net.source, + CMPI_chars); + + if (dev->dev.net.device != NULL) + CMSetProperty(inst, + "VirtualDevice", + (CMPIValue *)dev->dev.net.device, + CMPI_chars); + + if (dev->dev.net.model != NULL) + CMSetProperty(inst, + "ResourceSubType", + (CMPIValue *)dev->dev.net.model, + CMPI_chars); + + return s; +} + static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, CMPIInstance *inst, const char *name, @@ -429,27 +468,7 @@ if (dev->type == CIM_RES_TYPE_DISK) { s = set_disk_rasd_params(broker, ref, dev, inst); } else if (dev->type == CIM_RES_TYPE_NET) { - CMSetProperty(inst, - "NetworkType", - (CMPIValue *)dev->dev.net.type, - CMPI_chars); - CMSetProperty(inst, - "Address", - (CMPIValue *)dev->dev.net.mac, - CMPI_chars); - - if ((dev->dev.net.source != NULL) - && (STREQ(dev->dev.net.type, "bridge"))) - CMSetProperty(inst, - "NetworkName", - (CMPIValue *)dev->dev.net.source, - CMPI_chars); - - if (dev->dev.net.model != NULL) - CMSetProperty(inst, - "ResourceSubType", - (CMPIValue *)dev->dev.net.model, - CMPI_chars); + s = set_net_rasd_params(broker, ref, dev, inst); } else if (dev->type == CIM_RES_TYPE_MEM) { const char *units = "KiloBytes";

+1 Sharad Mishra System x Enablement Linux Technology Center IBM Kaitlin Rupert <kaitlin@linux.vn et.ibm.com> To Sent by: libvirt-cim@redhat.com libvirt-cim-bounc cc es@redhat.com Subject [Libvirt-cim] [PATCH 2 of 3] Add 01/28/2010 03:58 new attribute to hold the name of PM the net target device Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redh at.com> # HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 0273f86ebd7b6e54ec606d0a2a9aa54ce40246f1 # Parent 9532502f5d5e76efa998c4b6c9339cf47f91b914 Add new attribute to hold the name of the net target device VirtualDevice is used, as this is the same attribute used to hold the target device of a disk device. This patch also adds support for representing the target device in the device's RASD. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 9532502f5d5e -r 0273f86ebd7b schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Thu Jan 28 15:45:31 2010 -0800 +++ b/schema/ResourceAllocationSettingData.mof Thu Jan 28 15:45:31 2010 -0800 @@ -60,6 +60,8 @@ [Description ("Bridge name")] string NetworkName; + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("KVM virtual network configuration"), @@ -74,6 +76,8 @@ [Description ("Bridge name")] string NetworkName; + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("LXC virtual network configuration"), @@ -81,6 +85,8 @@ ] class LXC_NetResourceAllocationSettingData : LXC_ResourceAllocationSettingData { + [Description ("Target device as seen by the guest")] + string VirtualDevice; }; [Description ("Xen virtual processor"), diff -r 9532502f5d5e -r 0273f86ebd7b src/Virt_RASD.c --- a/src/Virt_RASD.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_RASD.c Thu Jan 28 15:45:31 2010 -0800 @@ -278,6 +278,45 @@ return s; } +static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, + "NetworkType", + (CMPIValue *)dev->dev.net.type, + CMPI_chars); + + CMSetProperty(inst, + "Address", + (CMPIValue *)dev->dev.net.mac, + CMPI_chars); + + if ((dev->dev.net.source != NULL) && + (STREQ(dev->dev.net.type, "bridge"))) + CMSetProperty(inst, + "NetworkName", + (CMPIValue *)dev->dev.net.source, + CMPI_chars); + + if (dev->dev.net.device != NULL) + CMSetProperty(inst, + "VirtualDevice", + (CMPIValue *)dev->dev.net.device, + CMPI_chars); + + if (dev->dev.net.model != NULL) + CMSetProperty(inst, + "ResourceSubType", + (CMPIValue *)dev->dev.net.model, + CMPI_chars); + + return s; +} + static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, CMPIInstance *inst, const char *name, @@ -429,27 +468,7 @@ if (dev->type == CIM_RES_TYPE_DISK) { s = set_disk_rasd_params(broker, ref, dev, inst); } else if (dev->type == CIM_RES_TYPE_NET) { - CMSetProperty(inst, - "NetworkType", - (CMPIValue *)dev->dev.net.type, - CMPI_chars); - CMSetProperty(inst, - "Address", - (CMPIValue *)dev->dev.net.mac, - CMPI_chars); - - if ((dev->dev.net.source != NULL) - && (STREQ(dev->dev.net.type, "bridge"))) - CMSetProperty(inst, - "NetworkName", - (CMPIValue *)dev->dev.net.source, - CMPI_chars); - - if (dev->dev.net.model != NULL) - CMSetProperty(inst, - "ResourceSubType", - (CMPIValue *)dev->dev.net.model, - CMPI_chars); + s = set_net_rasd_params(broker, ref, dev, inst); } else if (dev->type == CIM_RES_TYPE_MEM) { const char *units = "KiloBytes"; _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 5b37fac8372729a7da9817a8fc0661159fc710b8 # Parent 0273f86ebd7b6e54ec606d0a2a9aa54ce40246f1 Add support for defining a net device with the target device set Also provide template RASDs with the VirtualDevice attribute exposed. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 0273f86ebd7b -r 5b37fac83727 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Thu Jan 28 15:45:31 2010 -0800 @@ -546,6 +546,7 @@ const char *net_type, const char *net_name, uint64_t num_nics, + const char *device, const char *model, struct inst_list *list) { @@ -565,6 +566,10 @@ (CMPIValue *)&num_nics, CMPI_uint64); if (model != NULL) + CMSetProperty(inst, "VirtualDevice", + (CMPIValue *)device, CMPI_chars); + + if (model != NULL) CMSetProperty(inst, "ResourceSubType", (CMPIValue *)model, CMPI_chars); @@ -584,6 +589,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; int i,j; const char *type[] = {"network", "bridge", "user"}; + const char *device[] = {"vtap1", NULL}; const char *model[] = {"e1000", NULL}; const char *name[] = {NULL, "br0", NULL}; @@ -622,6 +628,7 @@ type[i], name[i], num_nics, + device[j], model[j], list); if (s.rc != CMPI_RC_OK) diff -r 0273f86ebd7b -r 5b37fac83727 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Thu Jan 28 15:45:31 2010 -0800 @@ -752,6 +752,13 @@ dev->dev.net.type = strdup(USER_TYPE); } else return "Invalid Network Type specified"; + + free(dev->dev.net.device); + if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) + dev->dev.net.device = NULL; + else + dev->dev.net.device = strdup(val); + free(dev->dev.net.model); if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK)

+1 Sharad Mishra System x Enablement Linux Technology Center IBM Kaitlin Rupert <kaitlin@linux.vn et.ibm.com>, To Sent by: libvirt-cim@redhat.com libvirt-cim-bounc cc es@redhat.com Subject [Libvirt-cim] [PATCH 3 of 3] Add 01/28/2010 03:59 support for defining a net device PM with the target device set Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redh at.com> # HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1264722331 28800 # Node ID 5b37fac8372729a7da9817a8fc0661159fc710b8 # Parent 0273f86ebd7b6e54ec606d0a2a9aa54ce40246f1 Add support for defining a net device with the target device set Also provide template RASDs with the VirtualDevice attribute exposed. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 0273f86ebd7b -r 5b37fac83727 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Thu Jan 28 15:45:31 2010 -0800 @@ -546,6 +546,7 @@ const char *net_type, const char *net_name, uint64_t num_nics, + const char *device, const char *model, struct inst_list *list) { @@ -565,6 +566,10 @@ (CMPIValue *)&num_nics, CMPI_uint64); if (model != NULL) + CMSetProperty(inst, "VirtualDevice", + (CMPIValue *)device, CMPI_chars); + + if (model != NULL) CMSetProperty(inst, "ResourceSubType", (CMPIValue *)model, CMPI_chars); @@ -584,6 +589,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; int i,j; const char *type[] = {"network", "bridge", "user"}; + const char *device[] = {"vtap1", NULL}; const char *model[] = {"e1000", NULL}; const char *name[] = {NULL, "br0", NULL}; @@ -622,6 +628,7 @@ type[i], name[i], num_nics, + device[j], model[j], list); if (s.rc != CMPI_RC_OK) diff -r 0273f86ebd7b -r 5b37fac83727 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Thu Jan 28 15:45:31 2010 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Thu Jan 28 15:45:31 2010 -0800 @@ -752,6 +752,13 @@ dev->dev.net.type = strdup(USER_TYPE); } else return "Invalid Network Type specified"; + + free(dev->dev.net.device); + if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) + dev->dev.net.device = NULL; + else + dev->dev.net.device = strdup(val); + free(dev->dev.net.model); if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Kaitlin Rupert
-
Sharad Mishra