
Deepak C Shetty <deepakcs@linux.vnet.ibm.com> Sent by: libvirt-cim-bounces@redhat.com
12/09/11 03:16 AM
Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com>
To
libvirt-cim@redhat.com
cc
Subject
[Libvirt-cim] [PATCH] Plan9fs (aka 9pfs, VirtFS) support for QEMU/ KVM environment
VirtFS is virtualization aware file system pass-through which provides
functionality to share host file system inside the guest. Its supported in libvirt via the <filesystem> xml node/tag. This patch introduces the filesystem support in KVM_DiskRASD and its associated changes needed to support VirtFS in libvirt-cim.
For further details... Virtfs home page/wiki : http://v9fs.sourceforge.net/ Virtfs setup for QEMU : http://wiki.qemu.org/Documentation/9psetup Virtfs support in libvirt : http://libvirt.org/formatdomain.html#elementsFilesystems
An example of the <filesystem> node in libvirt, supporting VirtFS... <filesystem type='mount' accessmode='passthrough'> <driver type='path'/> <source dir='/export/to/guest'/> <target dir='/import/from/host'/> <readonly/> </filesystem>
Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com> ---
libxkutil/device_parsing.c | 8 ++++++++ libxkutil/device_parsing.h | 1 + libxkutil/xmlgen.c | 15 +++++++++++++++ schema/ResourceAllocationSettingData.mof | 7 +++++-- src/Virt_RASD.c | 6 ++++++ src/Virt_RASD.h | 1 + src/Virt_VirtualSystemManagementService.c | 8 ++++++++ 7 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 371838f..6a09e7d 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -65,6 +65,7 @@ static void cleanup_disk_device(struct disk_device *dev) free(dev->source); free(dev->virtual_dev); free(dev->bus_type); + free(dev->access_mode); }
static void cleanup_vsi_device(struct vsi_device *dev) @@ -220,6 +221,8 @@ static int parse_fs_device(xmlNode *dnode, struct virt_device **vdevs) goto err; }
+ ddev->access_mode = get_attr_value(dnode, "accessmode"); + for (child = dnode->children; child != NULL; child = child-> next) { if (XSTREQ(child->name, "source")) { ddev->source = get_attr_value(child, "dir"); @@ -233,6 +236,8 @@ static int parse_fs_device(xmlNode *dnode, struct virt_device **vdevs) CU_DEBUG("No target dir"); goto err; } + } else if (XSTREQ(child->name, "driver")) { + ddev->driver_type = get_attr_value(child, "type"); } }
@@ -870,6 +875,7 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) DUP_FIELD(dev, _dev, dev.disk.source); DUP_FIELD(dev, _dev, dev.disk.virtual_dev); DUP_FIELD(dev, _dev, dev.disk.bus_type); + DUP_FIELD(dev, _dev, dev.disk.access_mode); dev->dev.disk.disk_type = _dev->dev.disk.disk_type; dev->dev.disk.readonly = _dev->dev.disk.readonly; dev->dev.disk.shareable = _dev->dev.disk.shareable; @@ -1436,6 +1442,8 @@ int disk_type_from_file(const char *path) return DISK_PHY; else if (S_ISREG(s.st_mode)) return DISK_FILE; + else if (S_ISDIR(s.st_mode)) + return DISK_FS; else return DISK_UNKNOWN; } diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index ab104d9..6bed040 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -55,6 +55,7 @@ struct disk_device { bool shareable; char *bus_type; char *cache; + char *access_mode; /* access modes for DISK_FS (filesystem) type */ };
struct net_device { diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4cca75b..44a6158 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -152,6 +152,21 @@ static const char *disk_fs_xml(xmlNodePtr root, struct disk_device *dev) if (fs == NULL) return XML_ERROR;
+ /* filesystem prop 'type' not needed to be generated, as it defaults + to 'mount' in libvirt, the only supported value for now. */ + + /* filesystem prop 'accessmode' defaults to 'passthrough' in
+ So generate here if specified by user, else leave it to
The patch looks good. Gareth is looking if we need to update SettingsDefineCapabilities for template. Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces@redhat.com wrote on 12/09/2011 03:16:56 AM: the libvirt. libvirt. */
+ + if (dev->access_mode) { + xmlNewProp(fs, BAD_CAST "accessmode", BAD_CAST dev->access_mode); + } + + if(dev->driver_type) { + tmp = xmlNewChild(fs, NULL, BAD_CAST "driver", NULL); + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev-> driver_type); + } + tmp = xmlNewChild(fs, NULL, BAD_CAST "source", NULL); if (tmp == NULL) return XML_ERROR; diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ ResourceAllocationSettingData.mof index 3da503d..108dff7 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -40,8 +40,8 @@ class KVM_DiskResourceAllocationSettingData : KVM_ResourceAllocationSettingData string VirtualDevice;
[Description ("Device emulation type"), - ValueMap {"0", "1", "2"}, - Values {"Disk", "CDROM", "floppy"}] + ValueMap {"0", "1", "2", "3"}, + Values {"Disk", "CDROM", "floppy", "filesystem"}] uint16 EmulatedType;
[Description ("Bus type of the device")] @@ -58,6 +58,9 @@ class KVM_DiskResourceAllocationSettingData : KVM_ResourceAllocationSettingData
[Description ("cache setting for device")] string DriverCache; + + [Description ("filesystem access mode")] + string AccessMode; };
[Description ("LXC virtual disk configuration"), diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 9305c8d..29bf10d 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -397,6 +397,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, (CMPIValue *)dev->dev.disk.cache, CMPI_chars);
+ if(dev->dev.disk.access_mode) + CMSetProperty(inst, + "AccessMode", + (CMPIValue *)dev->dev.disk.access_mode, + CMPI_chars); + virStoragePoolFree(pool); virStorageVolFree(vol); virConnectClose(conn); diff --git a/src/Virt_RASD.h b/src/Virt_RASD.h index 550543a..cef4224 100644 --- a/src/Virt_RASD.h +++ b/src/Virt_RASD.h @@ -26,6 +26,7 @@ #define VIRT_DISK_TYPE_DISK 0 #define VIRT_DISK_TYPE_CDROM 1 #define VIRT_DISK_TYPE_FLOPPY 2 +#define VIRT_DISK_TYPE_FS 3
char *rasd_to_xml(CMPIInstance *rasd);
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ Virt_VirtualSystemManagementService.c index 21979c3..3cdca86 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1022,6 +1022,8 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, } else if (type == VIRT_DISK_TYPE_FLOPPY) dev->dev.disk.device = strdup("floppy"); + else if (type == VIRT_DISK_TYPE_FS) + dev->dev.disk.device = strdup("filesystem"); else return "Invalid value for EmulatedType";
@@ -1056,6 +1058,12 @@ static const char *disk_rasd_to_vdev (CMPIInstance *inst, else dev->dev.disk.cache = strdup(val);
+ free(dev->dev.disk.access_mode); + if (cu_get_str_prop(inst, "AccessMode", &val) != CMPI_RC_OK) + dev->dev.disk.access_mode = NULL; + else + dev->dev.disk.access_mode = strdup(val); + free(dev->id); dev->id = strdup(dev->dev.disk.virtual_dev);
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim