[libvirt] [PATCHv12 1/3] libvirt/qemu - support persistent modification of devices
Eric Blake
eblake at redhat.com
Thu Apr 28 03:37:18 UTC 2011
On 04/21/2011 09:07 PM, KAMEZAWA Hiroyuki wrote:
>
> Rebased ont the latest git tree, which makes this work easier.
s/ont/onto/
> This series adds support for attach/detach/update disks of domain config.
> ==
> This patch adds functions for modify domain's persistent definition.
> To do error recovery in easy way, we use a copy of vmdef and update it.
>
> The whole sequence will be:
>
> make a copy of domain definition.
>
> if (flags & MODIFY_CONFIG)
> update copied domain definition
> if (flags & MODIF_LIVE)
> do hotplug.
> if (no error)
> save copied one to the file and update cached definition.
> else
> discard copied definition.
>
> This patch is mixuture of Eric Blake's work and mine.
> From: Eric Blake <eblake at redhat.com>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>
>
> Changelog: v11 -> v12
> - rebased and fixed hunks.
> - renamed qemudDomain....to qemuDomain...
>
> (virDomainObjCopyPersistentDef): make a copy of persistent vm definition
> (qemuDomainAttach/Detach/UpdateDeviceConfig) : callbacks. now empty
> (qemuDomainModifyDeviceFlags): add support for MODIFY_CONFIG and MODIFY_CURRENT
> ---
> src/conf/domain_conf.c | 18 ++++++
> src/conf/domain_conf.h | 3 +
> src/libvirt_private.syms | 1 +
> src/qemu/qemu_driver.c | 147 ++++++++++++++++++++++++++++++++++++----------
> 4 files changed, 137 insertions(+), 32 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 381e692..6c1098a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -9509,3 +9509,21 @@ cleanup:
>
> return ret;
> }
> +
> +
> +virDomainDefPtr
> +virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom)
> +{
> + char *xml;
> + virDomainDefPtr cur, ret;
> +
> + cur = virDomainObjGetPersistentDef(caps, dom);
> +
> + xml = virDomainDefFormat(cur, VIR_DOMAIN_XML_WRITE_FLAGS);
> + if (!xml)
> + return NULL;
> +
> + ret = virDomainDefParseString(caps, xml, VIR_DOMAIN_XML_READ_FLAGS);
Cute. Maybe not the most efficient, but very compact addition :)
> +
> + return ret;
But, it leaks xml.
> +}
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 6ea30b9..ddf111a 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1288,6 +1288,9 @@ int virDomainObjSetDefTransient(virCapsPtr caps,
> virDomainDefPtr
> virDomainObjGetPersistentDef(virCapsPtr caps,
> virDomainObjPtr domain);
> +virDomainDefPtr
> +virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom);
> +
> void virDomainRemoveInactive(virDomainObjListPtr doms,
> virDomainObjPtr dom);
>
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index ba7739d..f732431 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -287,6 +287,7 @@ virDomainMemballoonModelTypeToString;
> virDomainNetDefFree;
> virDomainNetTypeToString;
> virDomainObjAssignDef;
> +virDomainObjCopyPersistentDef;
> virDomainObjSetDefTransient;
> virDomainObjGetPersistentDef;
Pre-existing unsorted line.
Beyond that, it looks right to me. ACK!
I squashed this in, then pushed.
diff --git i/src/conf/domain_conf.c w/src/conf/domain_conf.c
index 2d413e7..691e50e 100644
--- i/src/conf/domain_conf.c
+++ w/src/conf/domain_conf.c
@@ -9526,5 +9526,6 @@ virDomainObjCopyPersistentDef(virCapsPtr caps,
virDomainObjPtr dom)
ret = virDomainDefParseString(caps, xml, VIR_DOMAIN_XML_READ_FLAGS);
+ VIR_FREE(xml);
return ret;
}
diff --git i/src/libvirt_private.syms w/src/libvirt_private.syms
index 52d7b02..579c62f 100644
--- i/src/libvirt_private.syms
+++ w/src/libvirt_private.syms
@@ -288,7 +288,6 @@ virDomainNetDefFree;
virDomainNetTypeToString;
virDomainObjAssignDef;
virDomainObjCopyPersistentDef;
-virDomainObjSetDefTransient;
virDomainObjGetPersistentDef;
virDomainObjIsDuplicate;
virDomainObjListDeinit;
@@ -298,6 +297,7 @@ virDomainObjListInit;
virDomainObjListNumOfDomains;
virDomainObjLock;
virDomainObjRef;
+virDomainObjSetDefTransient;
virDomainObjUnlock;
virDomainObjUnref;
virDomainRemoveInactive;
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110427/7eb2f54d/attachment-0001.sig>
More information about the libvir-list
mailing list