[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv12 1/3] libvirt/qemu - support persistent modification of devices



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 redhat com>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa hiroyu 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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]