[libvirt] [libvirt-glib] Add gvir_domain_update_device() and enums needed for it

This is a wrapper for virDomainUpdateDeviceFlags. --- libvirt-gobject/libvirt-gobject-domain.c | 42 ++++++++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain.h | 17 +++++++++++++ libvirt-gobject/libvirt-gobject.sym | 7 ++++++ 3 files changed, 66 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 8ade3ea..a00a042 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -1428,6 +1428,48 @@ GList *gvir_domain_get_devices(GVirDomain *domain, return g_list_reverse (ret); } + +/** + * gvir_domain_update_device: + * @dom: the domain + * @device: A modified device config + * @flags: bitwise-OR of #GVirDomainUpdateDeviceFlags + * @err: (allow-none):Place-holder for error or NULL + * + * Update the configuration of a device. + * + * Returns: TRUE if device was updated successfully, FALSE otherwise. + */ +gboolean +gvir_domain_update_device(GVirDomain *dom, + GVirConfigDomainDevice *device, + guint flags, + GError **err) +{ + gchar *xml; + + g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE); + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DEVICE(device), FALSE); + + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(device)); + g_return_val_if_fail(xml != NULL, FALSE); + + if (virDomainUpdateDeviceFlags(dom->priv->handle, + xml, flags) < 0) { + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Failed to update device"); + g_free (xml); + + return FALSE; + } + + g_free (xml); + return TRUE; +} + + /** * gvir_domain_create_snapshot: * @dom: the domain diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 6e7b10d..a622a46 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -158,6 +158,18 @@ typedef enum { GVIR_DOMAIN_SNAPSHOT_ATOMIC = VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC, } GVirDomainSnapshotCreateFlags; +/** + * GVirDomainUpdateDeviceFlags: + * @GVIR_DOMAIN_UPDATE_DEVICE_CURRENT: Update current domain state + * @GVIR_DOMAIN_UPDATE_DEVICE_LIVE: Update state for only active domains + * @GVIR_DOMAIN_UPDATE_DEVICE_CONFIG: Update state for persistent state only + */ +typedef enum { + GVIR_DOMAIN_UPDATE_DEVICE_CURRENT = VIR_DOMAIN_AFFECT_CURRENT, + GVIR_DOMAIN_UPDATE_DEVICE_LIVE = VIR_DOMAIN_AFFECT_LIVE, + GVIR_DOMAIN_UPDATE_DEVICE_CONFIG = VIR_DOMAIN_AFFECT_CONFIG, +} GVirDomainUpdateDeviceFlags; + typedef struct _GVirDomainInfo GVirDomainInfo; struct _GVirDomainInfo { @@ -294,6 +306,11 @@ gboolean gvir_domain_get_saved(GVirDomain *dom); GList *gvir_domain_get_devices(GVirDomain *domain, GError **err); +gboolean gvir_domain_update_device(GVirDomain *dom, + GVirConfigDomainDevice *device, + guint flags, + GError **err); + GVirDomainSnapshot * gvir_domain_create_snapshot(GVirDomain *dom, GVirConfigDomainSnapshot *custom_conf, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 3a40a8a..2034e89 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 { gvir_domain_wakeup_finish; } LIBVIRT_GOBJECT_0.1.2; +LIBVIRT_GOBJECT_0.1.4 { + global: + gvir_domain_update_device_flags_get_type; + gvir_domain_update_device; +} LIBVIRT_GOBJECT_0.1.3; + + # .... define new API here using predicted next version number .... -- 1.7.12.1

On Tue, Nov 13, 2012 at 7:10 PM, Alexander Larsson <alexl@redhat.com> wrote:
This is a wrapper for virDomainUpdateDeviceFlags.
Looks good. ACK.
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 3a40a8a..2034e89 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 { gvir_domain_wakeup_finish; } LIBVIRT_GOBJECT_0.1.2;
+LIBVIRT_GOBJECT_0.1.4 { + global: + gvir_domain_update_device_flags_get_type; + gvir_domain_update_device; +} LIBVIRT_GOBJECT_0.1.3;
I guess you need to rebase this on current git master? -- Regards, Zeeshan Ali (Khattak) FSF member#5124

On Tue, Nov 13, 2012 at 07:22:35PM +0100, Zeeshan Ali (Khattak) wrote:
On Tue, Nov 13, 2012 at 7:10 PM, Alexander Larsson <alexl@redhat.com> wrote:
This is a wrapper for virDomainUpdateDeviceFlags.
Looks good. ACK.
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 3a40a8a..2034e89 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 { gvir_domain_wakeup_finish; } LIBVIRT_GOBJECT_0.1.2;
+LIBVIRT_GOBJECT_0.1.4 { + global: + gvir_domain_update_device_flags_get_type; + gvir_domain_update_device; +} LIBVIRT_GOBJECT_0.1.3;
I guess you need to rebase this on current git master?
This looks good with respect to current git master, this part will indeed conflict with some of the patches that are up for review on the mailing list, maybe you have some of those applied? Christophe

On Tue, Nov 13, 2012 at 8:06 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
On Tue, Nov 13, 2012 at 07:22:35PM +0100, Zeeshan Ali (Khattak) wrote:
On Tue, Nov 13, 2012 at 7:10 PM, Alexander Larsson <alexl@redhat.com> wrote:
This is a wrapper for virDomainUpdateDeviceFlags.
Looks good. ACK.
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 3a40a8a..2034e89 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 { gvir_domain_wakeup_finish; } LIBVIRT_GOBJECT_0.1.2;
+LIBVIRT_GOBJECT_0.1.4 { + global: + gvir_domain_update_device_flags_get_type; + gvir_domain_update_device; +} LIBVIRT_GOBJECT_0.1.3;
I guess you need to rebase this on current git master?
This looks good with respect to current git master, this part will indeed conflict with some of the patches that are up for review on the mailing list, maybe you have some of those applied?
git tells me that origin/master is on 99e3677b836a86d24ea1f851 (gconfig: Add API to set domain/pm tree). Isn't that the case? -- Regards, Zeeshan Ali (Khattak) FSF member#5124

On Wed, Nov 14, 2012 at 01:12:39AM +0100, Zeeshan Ali (Khattak) wrote:
On Tue, Nov 13, 2012 at 8:06 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
On Tue, Nov 13, 2012 at 07:22:35PM +0100, Zeeshan Ali (Khattak) wrote:
On Tue, Nov 13, 2012 at 7:10 PM, Alexander Larsson <alexl@redhat.com> wrote:
This is a wrapper for virDomainUpdateDeviceFlags.
Looks good. ACK.
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 3a40a8a..2034e89 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 { gvir_domain_wakeup_finish; } LIBVIRT_GOBJECT_0.1.2;
+LIBVIRT_GOBJECT_0.1.4 { + global: + gvir_domain_update_device_flags_get_type; + gvir_domain_update_device; +} LIBVIRT_GOBJECT_0.1.3;
I guess you need to rebase this on current git master?
This looks good with respect to current git master, this part will indeed conflict with some of the patches that are up for review on the mailing list, maybe you have some of those applied?
git tells me that origin/master is on 99e3677b836a86d24ea1f851 (gconfig: Add API to set domain/pm tree). Isn't that the case?
It is, but the commit you refer to changes libvirt-gconfig/ while Alex's patch changes libvirt-gobject/, so no conflict there. Anyway, patch ACK'ed and pushed. Christophe
participants (3)
-
Alexander Larsson
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)