[PATCH 0 of 3] Complete LXC disk support

This set should finish off what is necessary to support disk devices on LXC guests.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1210005853 25200 # Node ID 577e78027b67fa2437418ae540bac190d4cdf50b # Parent 0b51247ab15043ace24a18b6ba56a40be765fb9c Add a field to the LXC_DiskRASD to hold the mount point within the guest This corresponds to the VirtualDevice field in the other DiskRASDs Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0b51247ab150 -r 577e78027b67 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Mon May 05 09:44:01 2008 -0700 +++ b/schema/ResourceAllocationSettingData.mof Mon May 05 09:44:13 2008 -0700 @@ -39,6 +39,10 @@ class KVM_DiskResourceAllocationSettingD ] class LXC_DiskResourceAllocationSettingData : LXC_ResourceAllocationSettingData { + + [Description ("Mount point within the container")] + string MountPoint; + }; [Description ("Xen virtual network configuration"),

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1210005853 25200 # Node ID 51420bb16e9a4e1ff1a125aa4333a6d29e6f8234 # Parent 577e78027b67fa2437418ae540bac190d4cdf50b Add support for defining an LXC guest with a DiskRASD Also, process the system information first, so that the device processing code can know what type of domain is being created. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 577e78027b67 -r 51420bb16e9a src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon May 05 09:44:13 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon May 05 09:44:13 2008 -0700 @@ -413,6 +413,27 @@ static const char *disk_rasd_to_vdev(CMP return NULL; } +static const char *lxc_disk_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + const char *val = NULL; + + if (cu_get_str_prop(inst, "MountPoint", &val) != CMPI_RC_OK) + return "Missing `MountPoint' field"; + + free(dev->dev.disk.virtual_dev); + dev->dev.disk.virtual_dev = strdup(val); + + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) + return "Missing `Address' field"; + + free(dev->dev.disk.source); + dev->dev.disk.source = strdup(val); + dev->dev.disk.disk_type = DISK_FS; + + return NULL; +} + static const char *mem_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { @@ -447,6 +468,8 @@ static const char *_container_rasd_to_vd { if (type == CIM_RES_TYPE_MEM) { return mem_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_DISK) { + return lxc_disk_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -611,20 +634,20 @@ static CMPIInstance *create_system(CMPII goto out; } + if (!vssd_to_domain(vssd, domain)) { + CU_DEBUG("Failed to create domain from VSSD"); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "SystemSettings Error"); + goto out; + } + msg = classify_resources(resources, NAMESPACE(ref), domain); if (msg != NULL) { CU_DEBUG("Failed to classify resources: %s", msg); cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, "ResourceSettings Error: %s", msg); - goto out; - } - - if (!vssd_to_domain(vssd, domain)) { - CU_DEBUG("Failed to create domain from VSSD"); - cu_statusf(_BROKER, s, - CMPI_RC_ERR_FAILED, - "SystemSettings Error"); goto out; }

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1210005853 25200 # Node ID 51420bb16e9a4e1ff1a125aa4333a6d29e6f8234 # Parent 577e78027b67fa2437418ae540bac190d4cdf50b Add support for defining an LXC guest with a DiskRASD
Also, process the system information first, so that the device processing code can know what type of domain is being created.
Good catch with the vssd_to_domain() change. +1 for this set. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1210005853 25200 # Node ID 2ec4259b46e7b0eeb275edbd8eb2d6051318b417 # Parent 51420bb16e9a4e1ff1a125aa4333a6d29e6f8234 Handle LXC disk XML generation Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 51420bb16e9a -r 2ec4259b46e7 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Mon May 05 09:44:13 2008 -0700 +++ b/libxkutil/xmlgen.c Mon May 05 09:44:13 2008 -0700 @@ -149,6 +149,24 @@ static char *disk_file_xml(const char *p return xml; } +static char *disk_fs_xml(const char *path, const char *vdev) +{ + char *xml; + int ret; + + ret = asprintf(&xml, + "<filesystem type='mount'>\n" + " <source dir='%s'/>\n" + " <target dir='%s'/>\n" + "</filesystem>\n", + path, + vdev); + if (ret == -1) + xml = NULL; + + return xml; +} + static bool disk_to_xml(char **xml, struct virt_device *dev) { char *_xml = NULL; @@ -160,6 +178,8 @@ static bool disk_to_xml(char **xml, stru /* If it's not a block device, we assume a file, which should be a reasonable fail-safe */ _xml = disk_file_xml(disk->source, disk->virtual_dev); + else if (disk->disk_type == DISK_FS) + _xml = disk_fs_xml(disk->source, disk->virtual_dev); else return false;
participants (2)
-
Dan Smith
-
Kaitlin Rupert