[Libvirt-cim] [PATCH] Add support for VSI/DCN
Chip Vincent
cvincent at linux.vnet.ibm.com
Thu Jul 1 15:59:55 UTC 2010
+1
NOTE: There appeared to be some whitespace differences for the last
chunk of Virt_SettingsDefineCapabilities.c. As such, I first push your
changes *except* that chunk, and then manually patched the whitespace issue.
Sharad Mishra wrote:
> # HG changeset patch
> # User Sharad Mishra <snmishra at us.ibm.com>
> # Date 1276810951 25200
> # Node ID a31f3f023acdd0edd73636a86a93c08803dd7158
> # Parent b2b8177338722a1f961430c8ccfe7820a5368ff7
> Add support for VSI/DCN.
>
> Signed-off-by: Sharad Mishra <snmishra at us.ibm.com>
>
> diff -r b2b817733872 -r a31f3f023acd libxkutil/device_parsing.c
> --- a/libxkutil/device_parsing.c Tue Jun 15 14:25:34 2010 -0700
> +++ b/libxkutil/device_parsing.c Thu Jun 17 14:42:31 2010 -0700
> @@ -58,6 +58,17 @@
> free(dev->bus_type);
> }
>
> +static void cleanup_vsi_device(struct vsi_device *dev)
> +{
> + free(dev->vsi_type);
> + free(dev->manager_id);
> + free(dev->type_id);
> + free(dev->type_id_version);
> + free(dev->instance_id);
> + free(dev->filter_ref);
> + free(dev->profile_id);
> +}
> +
> static void cleanup_net_device(struct net_device *dev)
> {
> free(dev->type);
> @@ -66,6 +77,7 @@
> free(dev->model);
> free(dev->device);
> free(dev->net_mode);
> + cleanup_vsi_device(&dev->vsi);
> }
>
> static void cleanup_emu_device(struct emu_device *dev)
> @@ -288,6 +300,7 @@
> {
> struct virt_device *vdev = NULL;
> struct net_device *ndev = NULL;
> + struct vsi_device *vsi_dev = NULL;
> xmlNode *child = NULL;
>
> vdev = calloc(1, sizeof(*vdev));
> @@ -295,6 +308,7 @@
> goto err;
>
> ndev = &(vdev->dev.net);
> + vsi_dev = &(ndev->vsi);
>
> ndev->type = get_attr_value(inode, "type");
> if (ndev->type == NULL)
> @@ -325,12 +339,28 @@
> ndev->model = get_attr_value(child, "type");
> if (ndev->model == NULL)
> goto err;
> + } else if (XSTREQ(child->name, "virtualport")) {
> + vsi_dev->vsi_type = get_attr_value(child, "type");
> + if (vsi_dev->vsi_type == NULL)
> + goto err;
> + } else if (XSTREQ(child->name, "parameters")) {
> + vsi_dev->manager_id = get_attr_value(child, "managerid");
> + if (vsi_dev->manager_id == NULL)
> + goto err;
> +
> + vsi_dev->type_id = get_attr_value(child, "typeid");
> + if (vsi_dev->type_id == NULL)
> + goto err;
> +
> + vsi_dev->type_id_version = get_attr_value(child, "typeidversion");
> + if (vsi_dev->type_id_version == NULL)
> + goto err;
> +
> + vsi_dev->instance_id = get_attr_value(child, "instanceid");
> + vsi_dev->profile_id = get_attr_value(child, "profileid");
> }
> }
>
> - if (ndev->mac == NULL)
> - goto err;
> -
> if (ndev->source == NULL)
> CU_DEBUG("No network source defined, leaving blank\n");
>
> @@ -602,6 +632,7 @@
> int len = 0;
> int count = 0;
>
> + CU_DEBUG("In parse_deviceso - type is %d", type);
> xmlDoc *xmldoc;
> xmlXPathContext *xpathCtx;
> xmlXPathObject *xpathObj;
> @@ -672,6 +703,13 @@
> DUP_FIELD(dev, _dev, dev.net.model);
> DUP_FIELD(dev, _dev, dev.net.device);
> DUP_FIELD(dev, _dev, dev.net.net_mode);
> + DUP_FIELD(dev, _dev, dev.net.vsi.vsi_type);
> + DUP_FIELD(dev, _dev, dev.net.vsi.manager_id);
> + DUP_FIELD(dev, _dev, dev.net.vsi.type_id);
> + DUP_FIELD(dev, _dev, dev.net.vsi.type_id_version);
> + DUP_FIELD(dev, _dev, dev.net.vsi.instance_id);
> + DUP_FIELD(dev, _dev, dev.net.vsi.filter_ref);
> + DUP_FIELD(dev, _dev, dev.net.vsi.profile_id);
> } else if (dev->type == CIM_RES_TYPE_DISK) {
> DUP_FIELD(dev, _dev, dev.disk.type);
> DUP_FIELD(dev, _dev, dev.disk.device);
> @@ -980,6 +1018,7 @@
> {
> int ret;
>
> + CU_DEBUG("In get_dominfo_from_xml");
> *dominfo = malloc(sizeof(**dominfo));
> if (*dominfo == NULL)
> return 0;
> @@ -1019,8 +1058,8 @@
> {
> char *xml;
> int ret;
> + xml = virDomainGetXMLDesc(dom, 0);
>
> - xml = virDomainGetXMLDesc(dom, 0);
> if (xml == NULL)
> return 0;
>
> diff -r b2b817733872 -r a31f3f023acd libxkutil/device_parsing.h
> --- a/libxkutil/device_parsing.h Tue Jun 15 14:25:34 2010 -0700
> +++ b/libxkutil/device_parsing.h Thu Jun 17 14:42:31 2010 -0700
> @@ -33,6 +33,16 @@
>
> #include "../src/svpc_types.h"
>
> +struct vsi_device {
> + char *vsi_type;
> + char *manager_id;
> + char *type_id;
> + char *type_id_version;
> + char *instance_id;
> + char *filter_ref;
> + char *profile_id;
> +};
> +
> struct disk_device {
> char *type;
> char *device;
> @@ -52,6 +62,7 @@
> char *model;
> char *device;
> char *net_mode;
> + struct vsi_device vsi;
> };
>
> struct mem_device {
> diff -r b2b817733872 -r a31f3f023acd libxkutil/xmlgen.c
> --- a/libxkutil/xmlgen.c Tue Jun 15 14:25:34 2010 -0700
> +++ b/libxkutil/xmlgen.c Thu Jun 17 14:42:31 2010 -0700
> @@ -159,6 +159,40 @@
> return msg;
> }
>
> +static const char *set_net_vsi(xmlNodePtr nic, struct vsi_device *dev)
> +{
> + xmlNodePtr tmp;
> +
> + tmp = xmlNewChild(nic, NULL, BAD_CAST "virtualport", NULL);
> + if (tmp == NULL)
> + return XML_ERROR;
> + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->vsi_type);
> +
> + tmp = xmlNewChild(tmp, NULL, BAD_CAST "parameters", NULL);
> + if (tmp == NULL)
> + return XML_ERROR;
> + if (STREQ(dev->vsi_type, "802.1Qbh")) {
> + if (dev->profile_id != NULL)
> + xmlNewProp(tmp, BAD_CAST "profileid",
> + BAD_CAST dev->profile_id);
> + } else {
> + if (dev->manager_id != NULL)
> + xmlNewProp(tmp, BAD_CAST "managerid",
> + BAD_CAST dev->manager_id);
> + if (dev->type_id != NULL)
> + xmlNewProp(tmp, BAD_CAST "typeid",
> + BAD_CAST dev->type_id);
> + if (dev->type_id_version != NULL)
> + xmlNewProp(tmp, BAD_CAST "typeidversion",
> + BAD_CAST dev->type_id_version);
> + if (dev->instance_id != NULL)
> + xmlNewProp(tmp, BAD_CAST "instanceid",
> + BAD_CAST dev->instance_id);
> + }
> +
> + return NULL;
> +}
> +
> static const char *set_net_source(xmlNodePtr nic,
> struct net_device *dev,
> const char *src_type)
> @@ -247,8 +281,13 @@
> msg = bridge_net_to_xml(nic, net);
> else if (STREQ(dev->dev.net.type, "user"))
> continue;
> - else if (STREQ(dev->dev.net.type, "direct"))
> + else if (STREQ(dev->dev.net.type, "direct")) {
> msg = set_net_source(nic, net, "direct");
> + if (net->vsi.vsi_type != NULL) {
> + struct vsi_device *vsi = &dev->dev.net.vsi;
> + msg = set_net_vsi(nic, vsi);
> + }
> + }
> else
> msg = "Unknown interface type";
> }
> diff -r b2b817733872 -r a31f3f023acd schema/ResourceAllocationSettingData.mof
> --- a/schema/ResourceAllocationSettingData.mof Tue Jun 15 14:25:34 2010 -0700
> +++ b/schema/ResourceAllocationSettingData.mof Thu Jun 17 14:42:31 2010 -0700
> @@ -68,6 +68,29 @@
>
> [Description ("Network mode, could be 'vepa', 'pepa' etc.")]
> string NetworkMode;
> +
> + [Description ("VSI type")]
> + string VSIType;
> +
> + [Description ("VSI manager id")]
> + string VSIManagerID;
> +
> + [Description ("VSI type")]
> + string VSITypeID;
> +
> + [Description ("expected/desired version of VTID")]
> + string VSITypeIDVersion;
> +
> + [Description ("A globally unique ID for the connection instance."
> + " The ID shall be done consistent with IETF RFC 4122.")]
> + string VSIInstanceID;
> +
> + [Description ("Profile ID")]
> + string ProfileID;
> +
> + [Description ("Filter REF")]
> + string FilterRef;
> +
> };
>
> [Description ("KVM virtual network configuration"),
> @@ -90,6 +113,28 @@
>
> [Description ("Network mode, could be 'vepa', 'pepa' etc.")]
> string NetworkMode;
> +
> + [Description ("VSI type")]
> + string VSIType;
> +
> + [Description ("VSI manager id")]
> + string VSIManagerID;
> +
> + [Description ("VSI type")]
> + string VSITypeID;
> +
> + [Description ("expected/desired version of VTID")]
> + string VSITypeIDVersion;
> +
> + [Description ("A globally unique ID for the connection instance."
> + " The ID shall be done consistent with IETF RFC 4122.")]
> + string VSIInstanceID;
> +
> + [Description ("Profile ID")]
> + string ProfileID;
> +
> + [Description ("Filter REF")]
> + string FilterRef;
> };
>
> [Description ("LXC virtual network configuration"),
> diff -r b2b817733872 -r a31f3f023acd src/Virt_RASD.c
> --- a/src/Virt_RASD.c Tue Jun 15 14:25:34 2010 -0700
> +++ b/src/Virt_RASD.c Thu Jun 17 14:42:31 2010 -0700
> @@ -278,6 +278,57 @@
> return s;
> }
>
> +static CMPIStatus set_net_vsi_rasd_params(const CMPIBroker *broker,
> + const CMPIObjectPath *ref,
> + const struct vsi_device vsi,
> + CMPIInstance *inst)
> +{
> + CMPIStatus s = {CMPI_RC_OK, NULL};
> +
> + CMSetProperty(inst,
> + "VSIType",
> + (CMPIValue *)vsi.vsi_type,
> + CMPI_chars);
> +
> + if (vsi.manager_id != NULL)
> + CMSetProperty(inst,
> + "VSIManagerID",
> + (CMPIValue *)vsi.manager_id,
> + CMPI_chars);
> +
> + if (vsi.type_id != NULL)
> + CMSetProperty(inst,
> + "VSITypeID",
> + (CMPIValue *)vsi.type_id,
> + CMPI_chars);
> +
> + if (vsi.type_id_version != NULL)
> + CMSetProperty(inst,
> + "VSITypeIDVersion",
> + (CMPIValue *)vsi.type_id_version,
> + CMPI_chars);
> +
> + if (vsi.instance_id != NULL)
> + CMSetProperty(inst,
> + "VSIInstanceID",
> + (CMPIValue *)vsi.instance_id,
> + CMPI_chars);
> +
> + if (vsi.filter_ref != NULL)
> + CMSetProperty(inst,
> + "FilterRef",
> + (CMPIValue *)vsi.filter_ref,
> + CMPI_chars);
> +
> + if (vsi.profile_id != NULL)
> + CMSetProperty(inst,
> + "ProfileID",
> + (CMPIValue *)vsi.profile_id,
> + CMPI_chars);
> +
> + return s;
> +}
> +
> static CMPIStatus set_net_rasd_params(const CMPIBroker *broker,
> const CMPIObjectPath *ref,
> const struct virt_device *dev,
> @@ -482,6 +533,13 @@
> s = set_disk_rasd_params(broker, ref, dev, inst);
> } else if (dev->type == CIM_RES_TYPE_NET) {
> s = set_net_rasd_params(broker, ref, dev, inst);
> + if ((s.rc == CMPI_RC_OK) &&
> + (dev->dev.net.vsi.vsi_type != NULL))
> + s = set_net_vsi_rasd_params(broker,
> + ref,
> + dev->dev.net.vsi,
> + inst);
> +
> } else if (dev->type == CIM_RES_TYPE_MEM) {
> const char *units = "KiloBytes";
>
> diff -r b2b817733872 -r a31f3f023acd src/Virt_SettingsDefineCapabilities.c
> --- a/src/Virt_SettingsDefineCapabilities.c Tue Jun 15 14:25:34 2010 -0700
> +++ b/src/Virt_SettingsDefineCapabilities.c Thu Jun 17 14:42:31 2010 -0700
> @@ -550,6 +550,12 @@
> const char *src_dev,
> const char *net_mode,
> const char *model,
> + const char *vsi,
> + const char *manager,
> + const char *typeid,
> + const char *version,
> + const char *instance,
> + const char *profile,
> struct inst_list *list)
> {
> CMPIInstance *inst;
> @@ -583,6 +589,31 @@
> CMSetProperty(inst, "ResourceSubType",
> (CMPIValue *)model, CMPI_chars);
>
> + if (vsi != NULL)
> + s = CMSetProperty(inst, "VSIType",
> + (CMPIValue *)vsi, CMPI_chars);
> +
> +
> + if (manager != NULL)
> + CMSetProperty(inst, "VSIManagerID",
> + (CMPIValue *)manager, CMPI_chars);
> +
> + if (typeid != NULL)
> + CMSetProperty(inst, "VSITypeID",
> + (CMPIValue *)typeid, CMPI_chars);
> +
> + if (version != NULL)
> + CMSetProperty(inst, "VSITypeIDVersion",
> + (CMPIValue *)version, CMPI_chars);
> +
> + if (instance != NULL)
> + CMSetProperty(inst, "VSIInstanceID",
> + (CMPIValue *)instance, CMPI_chars);
> +
> + if (profile != NULL)
> + CMSetProperty(inst, "ProfileID",
> + (CMPIValue *)profile, CMPI_chars);
> +
> inst_list_add(list, inst);
>
> out:
> @@ -600,8 +631,6 @@
> 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};
>
> @@ -641,17 +670,40 @@
> name[i],
> num_nics,
> device[j],
> - src_dev[j],
> - net_mode[j],
> + NULL,
> + NULL,
> model[j],
> + NULL,
> + NULL,
> + NULL,
> + NULL,
> + NULL,
> + NULL,
> 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);
> + s = set_net_props(template_type, ref, id, "direct", NULL,
> + num_nics, NULL, "eth1", "vepa", NULL,
> + NULL, NULL, NULL, NULL, NULL, NULL, list);
> + /* profile id*/
> + s = set_net_props(template_type, ref, id, "direct", NULL,
> + num_nics, NULL, "eth1", "vepa", NULL,
> + "802.1Qbh", NULL, NULL, NULL,
> + NULL, "my_profile", list);
> + /* no profile id but with instance id*/
> + s = set_net_props(template_type, ref, id, "direct", NULL,
> + num_nics, NULL, "eth1", "vepa", NULL,
> + "802.1Qbg", "managerid", "typeid",
> + "typeidversion", "instanceid", NULL,
> + list);
> + /* no profile id and no instance id*/
> + s = set_net_props(template_type, ref, id, "direct", NULL,
> + num_nics, NULL, "eth1", "vepa", NULL,
> + "802.1Qbg", "managerid", "typeid",
> + "typeidversion", "NULL", "NULL", list);
>
> out:
> return s;
> diff -r b2b817733872 -r a31f3f023acd src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c Tue Jun 15 14:25:34 2010 -0700
> +++ b/src/Virt_VirtualSystemManagementService.c Thu Jun 17 14:42:31 2010 -0700
> @@ -760,6 +760,50 @@
> return "Source Device is empty";
> else
> return "No Source Device specified";
> +
> + free(dev->dev.net.vsi.vsi_type);
> + if (cu_get_str_prop(inst, "VSIType", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.vsi_type = NULL;
> + else
> + dev->dev.net.vsi.vsi_type = strdup(val);
> +
> + free(dev->dev.net.vsi.manager_id);
> + if (cu_get_str_prop(inst, "VSIManagerID", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.manager_id = NULL;
> + else
> + dev->dev.net.vsi.manager_id = strdup(val);
> +
> + free(dev->dev.net.vsi.type_id);
> + if (cu_get_str_prop(inst, "VSITypeID", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.type_id = NULL;
> + else
> + dev->dev.net.vsi.type_id = strdup(val);
> +
> + free(dev->dev.net.vsi.type_id_version);
> + if (cu_get_str_prop(inst, "VSITypeIDVersion", &val) !=
> + CMPI_RC_OK)
> + dev->dev.net.vsi.type_id_version = NULL;
> + else
> + dev->dev.net.vsi.type_id_version = strdup(val);
> +
> + free(dev->dev.net.vsi.instance_id);
> + if (cu_get_str_prop(inst, "VSIInstanceID", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.instance_id = NULL;
> + else
> + dev->dev.net.vsi.instance_id = strdup(val);
> +
> + free(dev->dev.net.vsi.filter_ref);
> + if (cu_get_str_prop(inst, "FilterRef", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.filter_ref = NULL;
> + else
> + dev->dev.net.vsi.filter_ref = strdup(val);
> +
> + free(dev->dev.net.vsi.profile_id);
> + if (cu_get_str_prop(inst, "ProfileID", &val) != CMPI_RC_OK)
> + dev->dev.net.vsi.profile_id = NULL;
> + else
> + dev->dev.net.vsi.profile_id = strdup(val);
> +
> } else
> return "Invalid Network Type specified";
>
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>
--
Chip Vincent
Open Virtualization, Linux Technology Center
IBM Systems & Technology Group
phone: 919-254-4482, T/L 444-4482
email: cvincent at us.ibm.com
More information about the Libvirt-cim
mailing list