[PATCH 0 of 3] Add Vepa support

# HG changeset patch # User Sharad Mishra # Date 1266951039 28800 # Node ID 0a41b5e876d601216cb3257409eee231b4aec8b0 # Parent 5b37fac8372729a7da9817a8fc0661159fc710b8 Update xml parsing to support vepa. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 5b37fac83727 -r 0a41b5e876d6 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Thu Jan 28 15:45:31 2010 -0800 +++ b/libxkutil/device_parsing.c Tue Feb 23 10:50:39 2010 -0800 @@ -65,6 +65,7 @@ free(dev->source); free(dev->model); free(dev->device); + free(dev->net_mode); } static void cleanup_emu_device(struct emu_device *dev) @@ -311,6 +312,10 @@ ndev->source = get_attr_value(child, "network"); if (ndev->source != NULL) continue; + ndev->source = get_attr_value(child, "dev"); + ndev->net_mode = get_attr_value(child, "mode"); + if ((ndev->source != NULL) && (ndev->net_mode != NULL)) + continue; goto err; } else if (XSTREQ(child->name, "target")) { ndev->device = get_attr_value(child, "dev"); @@ -666,6 +671,7 @@ DUP_FIELD(dev, _dev, dev.net.source); DUP_FIELD(dev, _dev, dev.net.model); DUP_FIELD(dev, _dev, dev.net.device); + DUP_FIELD(dev, _dev, dev.net.net_mode); } else if (dev->type == CIM_RES_TYPE_DISK) { DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); diff -r 5b37fac83727 -r 0a41b5e876d6 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Thu Jan 28 15:45:31 2010 -0800 +++ b/libxkutil/device_parsing.h Tue Feb 23 10:50:39 2010 -0800 @@ -51,6 +51,7 @@ char *source; char *model; char *device; + char *net_mode; }; struct mem_device {

+1 Em 23-02-2010 15:21, Sharad Mishra escreveu:
# HG changeset patch # User Sharad Mishra # Date 1266951039 28800 # Node ID 0a41b5e876d601216cb3257409eee231b4aec8b0 # Parent 5b37fac8372729a7da9817a8fc0661159fc710b8 Update xml parsing to support vepa.
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
diff -r 5b37fac83727 -r 0a41b5e876d6 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Thu Jan 28 15:45:31 2010 -0800 +++ b/libxkutil/device_parsing.c Tue Feb 23 10:50:39 2010 -0800 @@ -65,6 +65,7 @@ free(dev->source); free(dev->model); free(dev->device); + free(dev->net_mode); }
static void cleanup_emu_device(struct emu_device *dev) @@ -311,6 +312,10 @@ ndev->source = get_attr_value(child, "network"); if (ndev->source != NULL) continue; + ndev->source = get_attr_value(child, "dev"); + ndev->net_mode = get_attr_value(child, "mode"); + if ((ndev->source != NULL)&& (ndev->net_mode != NULL)) + continue; goto err; } else if (XSTREQ(child->name, "target")) { ndev->device = get_attr_value(child, "dev"); @@ -666,6 +671,7 @@ DUP_FIELD(dev, _dev, dev.net.source); DUP_FIELD(dev, _dev, dev.net.model); DUP_FIELD(dev, _dev, dev.net.device); + DUP_FIELD(dev, _dev, dev.net.net_mode); } else if (dev->type == CIM_RES_TYPE_DISK) { DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); diff -r 5b37fac83727 -r 0a41b5e876d6 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Thu Jan 28 15:45:31 2010 -0800 +++ b/libxkutil/device_parsing.h Tue Feb 23 10:50:39 2010 -0800 @@ -51,6 +51,7 @@ char *source; char *model; char *device; + char *net_mode; };
struct mem_device {
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Sharad Mishra # Date 1266955062 28800 # Node ID 19918810d820fc1ea1296f4cf8c48ac442f571cb # Parent 0a41b5e876d601216cb3257409eee231b4aec8b0 Update mof and RASD to support Vepa Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 0a41b5e876d6 -r 19918810d820 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Tue Feb 23 10:50:39 2010 -0800 +++ b/schema/ResourceAllocationSettingData.mof Tue Feb 23 11:57:42 2010 -0800 @@ -62,6 +62,12 @@ [Description ("Target device as seen by the guest")] string VirtualDevice; + + [Description ("Source Device for bridge mode")] + string SourceDevice; + + [Description ("Network mode, could be 'vepa', 'pepa' etc.")] + string NetworkMode; }; [Description ("KVM virtual network configuration"), @@ -78,6 +84,12 @@ [Description ("Target device as seen by the guest")] string VirtualDevice; + + [Description ("Source Device for bridge mode")] + string SourceDevice; + + [Description ("Network mode, could be 'vepa', 'pepa' etc.")] + string NetworkMode; }; [Description ("LXC virtual network configuration"), diff -r 0a41b5e876d6 -r 19918810d820 src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Feb 23 10:50:39 2010 -0800 +++ b/src/Virt_RASD.c Tue Feb 23 11:57:42 2010 -0800 @@ -302,12 +302,25 @@ (CMPIValue *)dev->dev.net.source, CMPI_chars); + if ((dev->dev.net.source != NULL) && + (STREQ(dev->dev.net.type, "direct"))) + CMSetProperty(inst, + "SourceDevice", + (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.net_mode != NULL) + CMSetProperty(inst, + "NetworkMode", + (CMPIValue *)dev->dev.net.net_mode, + CMPI_chars); + if (dev->dev.net.model != NULL) CMSetProperty(inst, "ResourceSubType", diff -r 0a41b5e876d6 -r 19918810d820 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Feb 23 10:50:39 2010 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Feb 23 11:57:42 2010 -0800 @@ -547,6 +547,8 @@ const char *net_name, uint64_t num_nics, const char *device, + const char *src_dev, + const char *net_mode, const char *model, struct inst_list *list) { @@ -565,10 +567,18 @@ CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint64); - if (model != NULL) + if (device != NULL) CMSetProperty(inst, "VirtualDevice", (CMPIValue *)device, CMPI_chars); + if (net_mode != NULL) + CMSetProperty(inst, "NetworkMode", + (CMPIValue *)net_mode, CMPI_chars); + + if (src_dev != NULL) + CMSetProperty(inst, "SourceDevice", + (CMPIValue *)src_dev, CMPI_chars); + if (model != NULL) CMSetProperty(inst, "ResourceSubType", (CMPIValue *)model, CMPI_chars); @@ -590,6 +600,8 @@ int i,j; const char *type[] = {"network", "bridge", "user"}; const char *device[] = {"vtap1", NULL}; + const char *src_dev[] = {NULL, NULL}; + const char *net_mode[] = {NULL, NULL}; const char *model[] = {"e1000", NULL}; const char *name[] = {NULL, "br0", NULL}; @@ -629,13 +641,18 @@ name[i], num_nics, device[j], + src_dev[j], + net_mode[j], model[j], list); if (s.rc != CMPI_RC_OK) goto out; } } - + + s = set_net_props(template_type, ref, id, "direct", NULL, num_nics, + NULL, "eth1", "vepa", NULL, list); + out: return s; }

+1 Em 23-02-2010 15:21, Sharad Mishra escreveu:
# HG changeset patch # User Sharad Mishra # Date 1266955062 28800 # Node ID 19918810d820fc1ea1296f4cf8c48ac442f571cb # Parent 0a41b5e876d601216cb3257409eee231b4aec8b0 Update mof and RASD to support Vepa
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
diff -r 0a41b5e876d6 -r 19918810d820 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Tue Feb 23 10:50:39 2010 -0800 +++ b/schema/ResourceAllocationSettingData.mof Tue Feb 23 11:57:42 2010 -0800 @@ -62,6 +62,12 @@
[Description ("Target device as seen by the guest")] string VirtualDevice; + + [Description ("Source Device for bridge mode")] + string SourceDevice; + + [Description ("Network mode, could be 'vepa', 'pepa' etc.")] + string NetworkMode; };
[Description ("KVM virtual network configuration"), @@ -78,6 +84,12 @@
[Description ("Target device as seen by the guest")] string VirtualDevice; + + [Description ("Source Device for bridge mode")] + string SourceDevice; + + [Description ("Network mode, could be 'vepa', 'pepa' etc.")] + string NetworkMode; };
[Description ("LXC virtual network configuration"), diff -r 0a41b5e876d6 -r 19918810d820 src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Feb 23 10:50:39 2010 -0800 +++ b/src/Virt_RASD.c Tue Feb 23 11:57:42 2010 -0800 @@ -302,12 +302,25 @@ (CMPIValue *)dev->dev.net.source, CMPI_chars);
+ if ((dev->dev.net.source != NULL)&& + (STREQ(dev->dev.net.type, "direct"))) + CMSetProperty(inst, + "SourceDevice", + (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.net_mode != NULL) + CMSetProperty(inst, + "NetworkMode", + (CMPIValue *)dev->dev.net.net_mode, + CMPI_chars); + if (dev->dev.net.model != NULL) CMSetProperty(inst, "ResourceSubType", diff -r 0a41b5e876d6 -r 19918810d820 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Feb 23 10:50:39 2010 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Feb 23 11:57:42 2010 -0800 @@ -547,6 +547,8 @@ const char *net_name, uint64_t num_nics, const char *device, + const char *src_dev, + const char *net_mode, const char *model, struct inst_list *list) { @@ -565,10 +567,18 @@ CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint64);
- if (model != NULL) + if (device != NULL) CMSetProperty(inst, "VirtualDevice", (CMPIValue *)device, CMPI_chars);
+ if (net_mode != NULL) + CMSetProperty(inst, "NetworkMode", + (CMPIValue *)net_mode, CMPI_chars); + + if (src_dev != NULL) + CMSetProperty(inst, "SourceDevice", + (CMPIValue *)src_dev, CMPI_chars); + if (model != NULL) CMSetProperty(inst, "ResourceSubType", (CMPIValue *)model, CMPI_chars); @@ -590,6 +600,8 @@ int i,j; const char *type[] = {"network", "bridge", "user"}; const char *device[] = {"vtap1", NULL}; + const char *src_dev[] = {NULL, NULL}; + const char *net_mode[] = {NULL, NULL}; const char *model[] = {"e1000", NULL}; const char *name[] = {NULL, "br0", NULL};
@@ -629,13 +641,18 @@ name[i], num_nics, device[j], + src_dev[j], + net_mode[j], model[j], list); if (s.rc != CMPI_RC_OK) goto out; } } - + + s = set_net_props(template_type, ref, id, "direct", NULL, num_nics, + NULL, "eth1", "vepa", NULL, list); + out: return s; }
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Sharad Mishra # Date 1266955067 28800 # Node ID 94e67df60eb8ca8ce580c4a43b0958f6243d0f31 # Parent 19918810d820fc1ea1296f4cf8c48ac442f571cb Update xml generation to support vepa. Signed-of-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 19918810d820 -r 94e67df60eb8 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Tue Feb 23 11:57:42 2010 -0800 +++ b/libxkutil/xmlgen.c Tue Feb 23 11:57:47 2010 -0800 @@ -169,7 +169,14 @@ tmp = xmlNewChild(nic, NULL, BAD_CAST "source", NULL); if (tmp == NULL) return XML_ERROR; - xmlNewProp(tmp, BAD_CAST src_type, BAD_CAST dev->source); + if (STREQ(src_type, "direct")) { + xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source); + if (dev->net_mode != NULL) + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST dev->net_mode); + } else + xmlNewProp(tmp, BAD_CAST src_type, + BAD_CAST dev->source); } else return XML_ERROR; @@ -212,10 +219,12 @@ return XML_ERROR; xmlNewProp(nic, BAD_CAST "type", BAD_CAST net->type); - tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL); - if (tmp == NULL) - return XML_ERROR; - xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + if (net->mac != NULL) { + tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + } if (net->device != NULL) { tmp = xmlNewChild(nic, NULL, BAD_CAST "target", NULL); @@ -238,6 +247,8 @@ msg = bridge_net_to_xml(nic, net); else if (STREQ(dev->dev.net.type, "user")) continue; + else if (STREQ(dev->dev.net.type, "direct")) + msg = set_net_source(nic, net, "direct"); else msg = "Unknown interface type"; } diff -r 19918810d820 -r 94e67df60eb8 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Feb 23 11:57:42 2010 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Tue Feb 23 11:57:47 2010 -0800 @@ -63,6 +63,7 @@ #define BRIDGE_TYPE "bridge" #define NETWORK_TYPE "network" #define USER_TYPE "user" +#define DIRECT_TYPE "direct" #define RASD_IND_CREATED "ResourceAllocationSettingDataCreatedIndication" #define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" #define RASD_IND_MODIFIED "ResourceAllocationSettingDataModifiedIndication" @@ -750,6 +751,15 @@ dev->dev.net.source = strdup(network); } else if (STREQC(val, USER_TYPE)) { dev->dev.net.type = strdup(USER_TYPE); + } else if (STREQC(val, DIRECT_TYPE)) { + dev->dev.net.type = strdup(DIRECT_TYPE); + if (cu_get_str_prop(inst, "SourceDevice", &val) == CMPI_RC_OK) + if (strlen(val) > 0) + dev->dev.net.source = strdup(val); + else + return "Source Device is empty"; + else + return "No Source Device specified"; } else return "Invalid Network Type specified"; @@ -759,6 +769,12 @@ else dev->dev.net.device = strdup(val); + free(dev->dev.net.net_mode); + if (cu_get_str_prop(inst, "NetworkMode", &val) != CMPI_RC_OK) + dev->dev.net.net_mode = NULL; + else + dev->dev.net.net_mode = strdup(val); + free(dev->dev.net.model); if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK)

+1 Em 23-02-2010 15:21, Sharad Mishra escreveu:
# HG changeset patch # User Sharad Mishra # Date 1266955067 28800 # Node ID 94e67df60eb8ca8ce580c4a43b0958f6243d0f31 # Parent 19918810d820fc1ea1296f4cf8c48ac442f571cb Update xml generation to support vepa.
Signed-of-by: Sharad Mishra<snmishra@us.ibm.com>
diff -r 19918810d820 -r 94e67df60eb8 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Tue Feb 23 11:57:42 2010 -0800 +++ b/libxkutil/xmlgen.c Tue Feb 23 11:57:47 2010 -0800 @@ -169,7 +169,14 @@ tmp = xmlNewChild(nic, NULL, BAD_CAST "source", NULL); if (tmp == NULL) return XML_ERROR; - xmlNewProp(tmp, BAD_CAST src_type, BAD_CAST dev->source); + if (STREQ(src_type, "direct")) { + xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source); + if (dev->net_mode != NULL) + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST dev->net_mode); + } else + xmlNewProp(tmp, BAD_CAST src_type, + BAD_CAST dev->source); } else return XML_ERROR;
@@ -212,10 +219,12 @@ return XML_ERROR; xmlNewProp(nic, BAD_CAST "type", BAD_CAST net->type);
- tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL); - if (tmp == NULL) - return XML_ERROR; - xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + if (net->mac != NULL) { + tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "address", BAD_CAST net->mac); + }
if (net->device != NULL) { tmp = xmlNewChild(nic, NULL, BAD_CAST "target", NULL); @@ -238,6 +247,8 @@ msg = bridge_net_to_xml(nic, net); else if (STREQ(dev->dev.net.type, "user")) continue; + else if (STREQ(dev->dev.net.type, "direct")) + msg = set_net_source(nic, net, "direct"); else msg = "Unknown interface type"; } diff -r 19918810d820 -r 94e67df60eb8 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Feb 23 11:57:42 2010 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Tue Feb 23 11:57:47 2010 -0800 @@ -63,6 +63,7 @@ #define BRIDGE_TYPE "bridge" #define NETWORK_TYPE "network" #define USER_TYPE "user" +#define DIRECT_TYPE "direct" #define RASD_IND_CREATED "ResourceAllocationSettingDataCreatedIndication" #define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" #define RASD_IND_MODIFIED "ResourceAllocationSettingDataModifiedIndication" @@ -750,6 +751,15 @@ dev->dev.net.source = strdup(network); } else if (STREQC(val, USER_TYPE)) { dev->dev.net.type = strdup(USER_TYPE); + } else if (STREQC(val, DIRECT_TYPE)) { + dev->dev.net.type = strdup(DIRECT_TYPE); + if (cu_get_str_prop(inst, "SourceDevice",&val) == CMPI_RC_OK) + if (strlen(val)> 0) + dev->dev.net.source = strdup(val); + else + return "Source Device is empty"; + else + return "No Source Device specified"; } else return "Invalid Network Type specified";
@@ -759,6 +769,12 @@ else dev->dev.net.device = strdup(val);
+ free(dev->dev.net.net_mode); + if (cu_get_str_prop(inst, "NetworkMode",&val) != CMPI_RC_OK) + dev->dev.net.net_mode = NULL; + else + dev->dev.net.net_mode = 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

Sharad, the code looks good, but I can't test it because my libvirt version (0.7.6) doesn't support the "direct" network type. Which libvirt version are you using? Em 23-02-2010 15:21, Sharad Mishra escreveu:
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

On Tue, Mar 02, 2010 at 12:52:11PM -0500, Richard Maciel wrote:
Sharad, the code looks good, but I can't test it because my libvirt version (0.7.6) doesn't support the "direct" network type. Which libvirt version are you using?
That should be in 0.7.7, out hopefully by this week end, You can grab a snapshot for example: ftp://libvirt.org/libvirt/libvirt-git-snapshot.tar.gz Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Just to complement my last message: I saw that the libvirt domain XML was correctly generated by the provider, when I defined a new domain thru libvirt-cim. I also checked the RASD template and it is correct. So, to finish the tests, I just need to check if libvirt-cim can fetch the domain xml successfully and transform to a NetRASD instance. To do that, I need a libvirt that supports the "direct" type of interface device. Em 23-02-2010 15:21, Sharad Mishra escreveu:
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+1 Em 23-02-2010 15:21, Sharad Mishra escreveu:
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (3)
-
Daniel Veillard
-
Richard Maciel
-
Sharad Mishra