}
+static int
+virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+ virStorageSourcePtr src)
+{
+ virStorageSourcePtr backingStore = NULL;
+ xmlNodePtr save_ctxt = ctxt->node;
+ xmlNodePtr source;
+ char *type = NULL;
+ char *format = NULL;
+ int ret = -1;
+
+ if (!(ctxt->node = virXPathNode("./backingStore[*]", ctxt))) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (VIR_ALLOC(backingStore) < 0)
+ goto cleanup;
+
+ if (!(type = virXMLPropString(ctxt->node, "type"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing disk backing store type"));
+ goto cleanup;
+ }
+
+ backingStore->type = virStorageTypeFromString(type);
+ if (backingStore->type < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown disk backing store type '%s'"), type);
+ goto cleanup;
+ }
+
+ if (!(format = virXPathString("string(./format/@type)", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing disk backing store format"));
+ goto cleanup;
+ }
+
+ backingStore->format = virStorageFileFormatTypeFromString(format);
+ if (backingStore->format < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown disk backing store format '%s'"), format);
+ goto cleanup;
+ }
+
+ if (!(source = virXPathNode("./source", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing disk backing store source"));
+ goto cleanup;
+ }
+
+ if (virDomainDiskSourceParse(source, backingStore) < 0 ||
+ virDomainDiskBackingStoreParse(ctxt, backingStore) < 0)
+ goto cleanup;
+
+ src->backingStore = backingStore;
+ ret = 0;
+
+ cleanup:
+ if (ret < 0)
+ virStorageSourceFree(backingStore);
+ VIR_FREE(type);
+ VIR_FREE(format);
+ ctxt->node = save_ctxt;
+ return ret;
+}
+
+
#define VENDOR_LEN 8
#define PRODUCT_LEN 16
&& virDomainDiskDefAssignAddress(xmlopt, def) < 0)
goto error;
+ if (virDomainDiskBackingStoreParse(ctxt, &def->src) < 0)
+ goto error;
+
cleanup:
VIR_FREE(bus);
VIR_FREE(type);
}
+static int
+virDomainDiskBackingStoreFormat(virBufferPtr buf,
+ virStorageSourcePtr backingStore,
+ const char *backingStoreRaw,
+ unsigned int index)
+{
+ const char *type;
+ const char *format;
+
+ if (!backingStore) {
+ if (!backingStoreRaw)
+ virBufferAddLit(buf, "<backingStore/>\n");
+ return 0;
+ }
+
+ if (!backingStore->type ||
+ !(type = virStorageTypeToString(backingStore->type))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected disk backing store type %d"),
+ backingStore->type);
+ return -1;
+ }
+
+ if (backingStore->format <= 0 ||
+ !(format = virStorageFileFormatTypeToString(backingStore->format))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected disk backing store format %d"),
+ backingStore->format);
+ return -1;
+ }
+
+ virBufferAsprintf(buf, "<backingStore type='%s' index='%u'>\n",
+ type, index);
+ virBufferAdjustIndent(buf, 2);
+
+ virBufferAsprintf(buf, "<format type='%s'/>\n", format);
+ if (virDomainDiskSourceFormat(buf, backingStore, 0, 0) < 0 ||
+ virDomainDiskBackingStoreFormat(buf,
+ backingStore->backingStore,
+ backingStore->backingStoreRaw,
+ index + 1) < 0)
+ return -1;
+
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</backingStore>\n");
+ return 0;
+}
+
+
static int
virDomainDiskDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def,
if (virDomainDiskSourceFormat(buf, &def->src, def->startupPolicy,
flags) < 0)
return -1;
+
+ /* Don't format backingStore to inactive XMLs until the code for
+ * persistent storage of backing chains is ready. */
+ if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
+ virDomainDiskBackingStoreFormat(buf, def->src.backingStore,
+ def->src.backingStoreRaw, 1) < 0)
+ return -1;
+
virDomainDiskGeometryDefFormat(buf, def);
virDomainDiskBlockIoDefFormat(buf, def);
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
+ <backingStore/>
<mirror file='/dev/HostVG/QEMUGuest1Copy' ready='yes'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<source dev='/dev/HostVG/QEMUGuest2'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<disk type='file' device='disk'>
<source file='/tmp/data.img'/>
+ <backingStore/>
<mirror file='/tmp/copy.img' format='qcow2'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<source file='/tmp/logs.img'/>
+ <backingStore/>
<target dev='vdb' bus='virtio'/>
</disk>
<controller type='usb' index='0'/>
<source dev='/dev/HostVG/QEMUGuest1'>
<seclabel model='selinux' labelskip='yes'/>
</source>
+ <backingStore/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/MainVG/GuestVG'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<disk type='file' device='disk'>
<driver name='tap' type='raw'/>
<source file='/xen/rhel5.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<disk type='file' device='disk'>
<driver name='tap' type='raw'/>
<source file='/var/lib/xen/images/rhel5pv.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
<shareable/>
</disk>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/MainVG/GuestVG'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='tap' type='qcow'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='tap' type='raw'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='tap2' type='raw'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/iscsi/winxp'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<serial type='pty'>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/zvol/dsk/export/s10u4-root'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<input type='mouse' bus='ps2'/>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/foo.img'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/root/boot.iso'/>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='ethernet'>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/sda8'/>
+ <backingStore/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
+ <backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/MainVG/GuestVG'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/vg_dom0test/test2vm'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
+ <backingStore/>
<target dev='xvda' bus='xen'/>
</disk>
<console type='pty'>