It allows to set the optional elements "hv_user" and "hv_group" for a
guest.
hv_user and hv_group can be used to specify the user/group which own the
hypervisor.
Signed-off-by: Giuseppe Scrivano <gscrivan(a)redhat.com>
---
src/conf/capabilities.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/conf/capabilities.h | 7 +++++++
src/libvirt_private.syms | 1 +
3 files changed, 54 insertions(+)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1acc936..ffb1db5 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -169,6 +169,9 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
virCapabilitiesFreeGuestFeature(guest->features[i]);
VIR_FREE(guest->features);
+ VIR_FREE(guest->hvUser);
+ VIR_FREE(guest->hvGroup);
+
VIR_FREE(guest);
}
@@ -470,6 +473,43 @@ error:
/**
+ * virCapabilitiesSetHvUserAndGroup:
+ * @guest: guest to set HV user:group for.
+ * @user: name of the user which owns the hypervisor. Use NULL to unset.
+ * @group: name of the group which owns the hypervisor. Use NULL to unset.
+ *
+ * Set the user and the group which own the hypervisor.
+ */
+int
+virCapabilitiesSetHvUserAndGroup(virCapsGuestPtr guest,
+ const char *user,
+ const char *group)
+{
+ char *u = NULL;
+ char *g = NULL;
+
+ if (user && VIR_STRDUP(u, user) < 0)
+ goto no_memory;
+
+ if (group && VIR_STRDUP(g, group) < 0)
+ goto no_memory;
+
+ VIR_FREE(guest->hvUser);
+ VIR_FREE(guest->hvGroup);
+
+ guest->hvUser = u;
+ guest->hvGroup = g;
+
+ return 0;
+
+no_memory:
+ VIR_FREE(u);
+ VIR_FREE(g);
+ return -1;
+}
+
+
+/**
* virCapabilitiesAddGuestFeature:
* @guest: guest to associate feature with
* @name: name of feature ('pae', 'acpi', 'apic')
@@ -903,6 +943,12 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " </features>\n");
}
+ if (caps->guests[i]->hvUser)
+ virBufferAsprintf(&xml, "
<hv_user>%s</hv_user>\n",
+ caps->guests[i]->hvUser);
+ if (caps->guests[i]->hvGroup)
+ virBufferAsprintf(&xml, "
<hv_group>%s</hv_group>\n",
+ caps->guests[i]->hvGroup);
virBufferAddLit(&xml, " </guest>\n\n");
}
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 88ec454..a6fe7e0 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -80,6 +80,8 @@ typedef struct _virCapsGuest virCapsGuest;
typedef virCapsGuest *virCapsGuestPtr;
struct _virCapsGuest {
char *ostype;
+ char *hvUser;
+ char *hvGroup;
virCapsGuestArch arch;
size_t nfeatures;
size_t nfeatures_max;
@@ -218,6 +220,11 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
int nmachines,
virCapsGuestMachinePtr *machines);
+extern int
+virCapabilitiesSetHvUserAndGroup(virCapsGuestPtr guest,
+ const char *user,
+ const char *group);
+
extern virCapsGuestFeaturePtr
virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
const char *name,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c25a61f..41219d6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -60,6 +60,7 @@ virCapabilitiesFreeNUMAInfo;
virCapabilitiesGetCpusForNodemask;
virCapabilitiesNew;
virCapabilitiesSetHostCPU;
+virCapabilitiesSetHvUserAndGroup;
# conf/cpu_conf.h
--
1.8.3.1