[libvirt] [PATCH 07/12] conf: support backend domain name in disk and network devices
by Marek Marczykowski
At least Xen supports backend drivers in another domain (aka "driver
domain"). This patch introduces XML config option for such setting as
'domain' element with 'name' attribute. Verification its content is left
for the driver.
In the future some option will be needed for USB devices (hostdev
objects), but for now libxl doesn't have support for PVUSB.
---
docs/schemas/domaincommon.rng | 14 ++++++++++++++
src/conf/domain_conf.c | 27 +++++++++++++++++++++++++++
src/conf/domain_conf.h | 2 ++
3 files changed, 43 insertions(+)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 8d7e6db..1423187 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -869,6 +869,13 @@
</optional>
<ref name="target"/>
<optional>
+ <element name="domain">
+ <attribute name="name">
+ <ref name="domainName"/>
+ </attribute>
+ </element>
+ </optional>
+ <optional>
<ref name="deviceBoot"/>
</optional>
<optional>
@@ -1834,6 +1841,13 @@
</element>
</optional>
<optional>
+ <element name="domain">
+ <attribute name="name">
+ <ref name="domainName"/>
+ </attribute>
+ </element>
+ </optional>
+ <optional>
<element name="model">
<attribute name="type">
<data type="string">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 257a265..bf1fec6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1103,6 +1103,7 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->vendor);
VIR_FREE(def->product);
VIR_FREE(def->script);
+ VIR_FREE(def->domain_name);
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
VIR_FREE(def->auth.secret.usage);
virStorageEncryptionFree(def->encryption);
@@ -1228,6 +1229,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(def->virtPortProfile);
VIR_FREE(def->script);
+ VIR_FREE(def->domain_name);
VIR_FREE(def->ifname);
virDomainDeviceInfoClear(&def->info);
@@ -3995,6 +3997,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
char *vendor = NULL;
char *product = NULL;
char *script = NULL;
+ char *domain_name = NULL;
int expected_secret_usage = -1;
int auth_secret_usage = -1;
@@ -4153,6 +4156,9 @@ virDomainDiskDefParseXML(virCapsPtr caps,
} else if (!script &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
script = virXMLPropString(cur, "path");
+ } else if (!domain_name &&
+ xmlStrEqual(cur->name, BAD_CAST "domain")) {
+ domain_name = virXMLPropString(cur, "name");
} else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) {
if (virXPathUInt("string(./geometry/@cyls)",
ctxt, &def->geometry.cylinders) < 0) {
@@ -4447,6 +4453,11 @@ virDomainDiskDefParseXML(virCapsPtr caps,
ctxt->node = saved_node;
}
+ if (domain_name != NULL) {
+ def->domain_name = domain_name;
+ domain_name = NULL;
+ }
+
if (target == NULL) {
virReportError(VIR_ERR_NO_TARGET,
source ? "%s" : NULL, source);
@@ -4796,6 +4807,7 @@ cleanup:
VIR_FREE(vendor);
VIR_FREE(product);
VIR_FREE(script);
+ VIR_FREE(domain_name);
ctxt->node = save_ctxt;
return def;
@@ -5353,6 +5365,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
char *mode = NULL;
char *linkstate = NULL;
char *addrtype = NULL;
+ char *domain_name = NULL;
virNWFilterHashTablePtr filterparams = NULL;
virDomainActualNetDefPtr actual = NULL;
xmlNodePtr oldnode = ctxt->node;
@@ -5451,6 +5464,9 @@ virDomainNetDefParseXML(virCapsPtr caps,
} else if (!script &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
script = virXMLPropString(cur, "path");
+ } else if (!domain_name &&
+ xmlStrEqual(cur->name, BAD_CAST "domain")) {
+ domain_name = virXMLPropString(cur, "name");
} else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
model = virXMLPropString(cur, "type");
} else if (xmlStrEqual(cur->name, BAD_CAST "driver")) {
@@ -5682,6 +5698,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
def->script = script;
script = NULL;
}
+ if (domain_name != NULL) {
+ def->domain_name = domain_name;
+ domain_name = NULL;
+ }
if (ifname != NULL) {
def->ifname = ifname;
ifname = NULL;
@@ -5808,6 +5828,7 @@ cleanup:
VIR_FREE(mode);
VIR_FREE(linkstate);
VIR_FREE(addrtype);
+ VIR_FREE(domain_name);
virNWFilterHashTableFree(filterparams);
return def;
@@ -12909,6 +12930,10 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, " <script path='%s'/>\n", def->script);
+ if (def->domain_name) {
+ virBufferEscapeString(buf, " <domain name='%s'/>\n", def->domain_name);
+ }
+
virDomainDiskGeometryDefFormat(buf, def);
virDomainDiskBlockIoDefFormat(buf, def);
@@ -13456,6 +13481,8 @@ virDomainNetDefFormat(virBufferPtr buf,
return -1;
virBufferEscapeString(buf, "<script path='%s'/>\n",
def->script);
+ if (def->domain_name)
+ virBufferEscapeString(buf, "<domain name='%s'/>\n", def->domain_name);
if (def->ifname &&
!((flags & VIR_DOMAIN_XML_INACTIVE) &&
(STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d55d209..db3002b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -669,6 +669,7 @@ struct _virDomainDiskDef {
int rawio; /* no = 0, yes = 1 */
int sgio; /* enum virDomainDiskSGIO */
char *script;
+ char *domain_name; /* backend domain name */
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
@@ -919,6 +920,7 @@ struct _virDomainNetDef {
unsigned long sndbuf;
} tune;
char *script;
+ char *domain_name; /* backend domain name */
char *ifname;
virDomainDeviceInfo info;
char *filter;
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 09/12] libxl: fill HVM SDL and VNC settings based on <graphics/> entries
by Marek Marczykowski
Vfb entries in domain config are used only by PV drivers. Qemu parameters are
build based on b_info struct. So fill it with the same data as vfb entries
(actually the first one).
This will additionally allow graphic-less domain, when no <graphics/> entries
are present in domain XML (previously VNC was always enabled).
---
src/libxl/libxl_conf.c | 131 +++++++++++++++++++++++++++++++++----------------
1 file changed, 90 insertions(+), 41 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 477e46d..068a97a 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -347,7 +347,64 @@ error:
}
static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeVNCInfo(libxlDriverPrivatePtr driver,
+ virDomainGraphicsDefPtr l_vfb,
+ libxl_vnc_info *x_vnc)
+{
+ unsigned short port;
+ const char *listenAddr;
+
+ libxl_defbool_set(&x_vnc->enable, 1);
+ /* driver handles selection of free port */
+ libxl_defbool_set(&x_vnc->findunused, 0);
+ if (l_vfb->data.vnc.autoport) {
+
+ if (virPortAllocatorAcquire(driver->reservedVNCPorts, &port) < 0)
+ return -1;
+ if (port == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Unable to find an unused VNC port"));
+ return -1;
+ }
+ l_vfb->data.vnc.port = port;
+ }
+ x_vnc->display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN;
+
+ listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0);
+ if (listenAddr) {
+ /* libxl_device_vfb_init() does strdup("127.0.0.1") */
+ VIR_FREE(x_vnc->listen);
+ if ((x_vnc->listen = strdup(listenAddr)) == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int
+libxlMakeSDLInfo(virDomainGraphicsDefPtr l_vfb,
+ libxl_sdl_info *x_sdl)
+{
+ libxl_defbool_set(&x_sdl->enable, 1);
+ if (l_vfb->data.sdl.display &&
+ (x_sdl->display = strdup(l_vfb->data.sdl.display)) == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+ if (l_vfb->data.sdl.xauth &&
+ (x_sdl->xauthority =
+ strdup(l_vfb->data.sdl.xauth)) == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+ return 0;
+}
+
+static int
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver,
+ virDomainDefPtr def,
+ libxl_domain_config *d_config)
{
libxl_domain_build_info *b_info = &d_config->b_info;
int hvm = STREQ(def->os.type, "hvm");
@@ -421,6 +478,34 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
goto error;
}
+ /* Disable VNC and SDL until explicitly enabled */
+ libxl_defbool_set(&b_info->u.hvm.vnc.enable, 0);
+ libxl_defbool_set(&b_info->u.hvm.sdl.enable, 0);
+
+ for (i = 0; i < def->ngraphics; i++) {
+ switch (def->graphics[i]->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ if (libxl_defbool_val(b_info->u.hvm.vnc.enable))
+ continue;
+ if (libxlMakeVNCInfo(driver, def->graphics[i],
+ &b_info->u.hvm.vnc) < 0)
+ goto error;
+ if (def->graphics[i]->data.vnc.keymap &&
+ (b_info->u.hvm.keymap =
+ strdup(def->graphics[i]->data.vnc.keymap)) == NULL) {
+ virReportOOMError();
+ goto error;
+ }
+ break;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ if (libxl_defbool_val(b_info->u.hvm.sdl.enable))
+ continue;
+ if (libxlMakeSDLInfo(def->graphics[i], &b_info->u.hvm.sdl) < 0)
+ goto error;
+ break;
+ }
+ }
+
/*
* The following comment and calculation were taken directly from
* libxenlight's internal function libxl_get_required_shadow_memory():
@@ -706,50 +791,14 @@ libxlMakeVfb(libxlDriverPrivatePtr driver,
virDomainGraphicsDefPtr l_vfb,
libxl_device_vfb *x_vfb)
{
- unsigned short port;
- const char *listenAddr;
-
switch (l_vfb->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
- libxl_defbool_set(&x_vfb->sdl.enable, 1);
- if (l_vfb->data.sdl.display &&
- (x_vfb->sdl.display = strdup(l_vfb->data.sdl.display)) == NULL) {
- virReportOOMError();
- return -1;
- }
- if (l_vfb->data.sdl.xauth &&
- (x_vfb->sdl.xauthority =
- strdup(l_vfb->data.sdl.xauth)) == NULL) {
- virReportOOMError();
+ if (libxlMakeSDLInfo(l_vfb, &x_vfb->sdl) < 0)
return -1;
- }
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
- libxl_defbool_set(&x_vfb->vnc.enable, 1);
- /* driver handles selection of free port */
- libxl_defbool_set(&x_vfb->vnc.findunused, 0);
- if (l_vfb->data.vnc.autoport) {
-
- if (virPortAllocatorAcquire(driver->reservedVNCPorts, &port) < 0)
- return -1;
- if (port == 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Unable to find an unused VNC port"));
- return -1;
- }
- l_vfb->data.vnc.port = port;
- }
- x_vfb->vnc.display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN;
-
- listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0);
- if (listenAddr) {
- /* libxl_device_vfb_init() does strdup("127.0.0.1") */
- VIR_FREE(x_vfb->vnc.listen);
- if ((x_vfb->vnc.listen = strdup(listenAddr)) == NULL) {
- virReportOOMError();
- return -1;
- }
- }
+ if (libxlMakeVNCInfo(driver, l_vfb, &x_vfb->vnc) < 0)
+ return -1;
if (l_vfb->data.vnc.keymap &&
(x_vfb->keymap =
strdup(l_vfb->data.vnc.keymap)) == NULL) {
@@ -920,7 +969,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
return -1;
- if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+ if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
goto error;
}
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 10/12] RFC: libxl: special 'stubdom-dm' emulator to use qemu in stub domain
by Marek Marczykowski
Xen have feature of having device model in separate domain (called stub
domain). It used to be enabled by special 'stubdom-dm' device model path.
Recent xl have separate config option for this feature
(device_model_stubdomain_override), but I'm not sure if it worth introducing
another xen-specific option in general domain XML syntax.
Also use os->cmdline as extra arguments for qemu (for HVM only). This use of
os->cmdline is rather dirty hack, but I haven't idea what better attribute use
for it. Perhaps worth new attribute (in <emulator/> element?). Anyway
os->cmdline was unused for HVM domains.
---
src/libxl/libxl_conf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 068a97a..181d344 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -478,6 +478,18 @@ libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver,
goto error;
}
+ if (def->emulator && strcmp(def->emulator, "stubdom-dm")==0) {
+ libxl_defbool_set(&b_info->device_model_stubdomain, 1);
+ }
+
+ if (def->os.cmdline && def->os.cmdline[0]) {
+ b_info->extra_hvm = virStringSplit(def->os.cmdline, " ", 0);
+ if (b_info->extra_hvm == NULL) {
+ virReportOOMError();
+ goto error;
+ }
+ }
+
/* Disable VNC and SDL until explicitly enabled */
libxl_defbool_set(&b_info->u.hvm.vnc.enable, 0);
libxl_defbool_set(&b_info->u.hvm.sdl.enable, 0);
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 11/12] conf: virDomainObjListRemoveLocked function
by Marek Marczykowski
While iterating with virDomainObjListForEach it is safe to remove
current element. But while iterating, 'doms' lock is already taken, so
can't use standard virDomainObjListRemove. So introduce
virDomainObjListRemoveLocked for this purpose. This is required to fix deadlock
in libxl driver.
---
src/conf/domain_conf.c | 17 +++++++++++++++++
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
3 files changed, 20 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bf1fec6..e4f7288 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2199,6 +2199,23 @@ void virDomainObjListRemove(virDomainObjListPtr doms,
virObjectUnlock(doms);
}
+/* The caller must hold lock on 'doms' in addition to 'virDomainObjListRemove'
+ * requirements
+ *
+ * Can be used to remove current element while iterating with
+ * virDomainObjListForEach
+ */
+void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
+ virDomainObjPtr dom)
+{
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(dom->def->uuid, uuidstr);
+ virObjectUnlock(dom);
+
+ virHashRemoveEntry(doms->objs, uuidstr);
+}
+
static int
virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index db3002b..e34143b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2073,6 +2073,8 @@ virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLConfPtr xmlconf,
void virDomainObjListRemove(virDomainObjListPtr doms,
virDomainObjPtr dom);
+void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
+ virDomainObjPtr dom);
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
virDomainDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 96eea0a..e6b6b1b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -270,6 +270,7 @@ virDomainObjListLoadAllConfigs;
virDomainObjListNew;
virDomainObjListNumOfDomains;
virDomainObjListRemove;
+virDomainObjListRemoveLocked;
virDomainObjNew;
virDomainObjSetDefTransient;
virDomainObjSetState;
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 08/12] libxl: support backend domain setting for disk and net devices
by Marek Marczykowski
This implement handling of <domain name=''/> parameter introduced in previous
patch.
Lookup on domain name (to get domain ID) requires libxlDriverPrivate
object, so it must be passed down to libxlMakeDisk and libxlMakeNet from
top level callers.
---
src/libxl/libxl_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++-------
src/libxl/libxl_conf.h | 4 ++--
src/libxl/libxl_driver.c | 50 +++++++++++++++++++++-----------------
3 files changed, 84 insertions(+), 32 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4bd62e9..477e46d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -472,7 +472,9 @@ error:
}
int
-libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
+libxlMakeDisk(libxlDriverPrivatePtr driver,
+ virDomainDiskDefPtr l_disk,
+ libxl_device_disk *x_disk)
{
if (l_disk->src && (x_disk->pdev_path = strdup(l_disk->src)) == NULL) {
virReportOOMError();
@@ -549,11 +551,32 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
return -1;
}
+ if (l_disk->domain_name) {
+ uint32_t domid;
+ /* Do not use virDomainObjListFindByName as it causes deadlock here -
+ * we already have lock on this domain object, but
+ * virDomainObjListFindByName will try to take it again.
+ */
+ switch (libxl_name_to_domid(driver->ctx, l_disk->domain_name, &domid)) {
+ case ERROR_INVAL:
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("Disk backend domain '%s' does not exists"),
+ l_disk->domain_name);
+ return -1;
+ case ERROR_NOMEM:
+ virReportOOMError();
+ return -1;
+ }
+ x_disk->backend_domid = domid;
+ }
+
return 0;
}
static int
-libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDiskList(libxlDriverPrivatePtr driver,
+ virDomainDefPtr def,
+ libxl_domain_config *d_config)
{
virDomainDiskDefPtr *l_disks = def->disks;
int ndisks = def->ndisks;
@@ -566,7 +589,7 @@ libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
}
for (i = 0; i < ndisks; i++) {
- if (libxlMakeDisk(l_disks[i], &x_disks[i]) < 0)
+ if (libxlMakeDisk(driver, l_disks[i], &x_disks[i]) < 0)
goto error;
}
@@ -583,7 +606,9 @@ error:
}
int
-libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic)
+libxlMakeNic(libxlDriverPrivatePtr driver,
+ virDomainNetDefPtr l_nic,
+ libxl_device_nic *x_nic)
{
/* TODO: Where is mtu stored?
*
@@ -620,11 +645,32 @@ libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic)
return -1;
}
+ if (l_nic->domain_name) {
+ uint32_t domid;
+ /* Do not use virDomainObjListFindByName as it causes deadlock here -
+ * we already have lock on this domain object, but
+ * virDomainObjListFindByName will try to take it again.
+ */
+ switch (libxl_name_to_domid(driver->ctx, l_nic->domain_name, &domid)) {
+ case ERROR_INVAL:
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("Network backend domain '%s' does not exists"),
+ l_nic->domain_name);
+ return -1;
+ case ERROR_NOMEM:
+ virReportOOMError();
+ return -1;
+ }
+ x_nic->backend_domid = domid;
+ }
+
return 0;
}
static int
-libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeNicList(libxlDriverPrivatePtr driver,
+ virDomainDefPtr def,
+ libxl_domain_config *d_config)
{
virDomainNetDefPtr *l_nics = def->nets;
int nnics = def->nnets;
@@ -639,7 +685,7 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
for (i = 0; i < nnics; i++) {
x_nics[i].devid = i;
- if (libxlMakeNic(l_nics[i], &x_nics[i]))
+ if (libxlMakeNic(driver, l_nics[i], &x_nics[i]))
goto error;
}
@@ -878,11 +924,11 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
goto error;
}
- if (libxlMakeDiskList(def, d_config) < 0) {
+ if (libxlMakeDiskList(driver, def, d_config) < 0) {
goto error;
}
- if (libxlMakeNicList(def, d_config) < 0) {
+ if (libxlMakeNicList(driver, def, d_config) < 0) {
goto error;
}
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index b3ab3bf..99948b5 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -113,9 +113,9 @@ virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx);
int
-libxlMakeDisk(virDomainDiskDefPtr l_dev, libxl_device_disk *x_dev);
+libxlMakeDisk(libxlDriverPrivatePtr driver, virDomainDiskDefPtr l_dev, libxl_device_disk *x_dev);
int
-libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic);
+libxlMakeNic(libxlDriverPrivatePtr driver, virDomainNetDefPtr l_nic, libxl_device_nic *x_nic);
int
libxlMakeVfb(libxlDriverPrivatePtr driver,
virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 89546a5..b0f0c6a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3166,8 +3166,9 @@ libxlDomainUndefine(virDomainPtr dom)
}
static int
-libxlDomainChangeEjectableMedia(libxlDomainObjPrivatePtr priv,
- virDomainObjPtr vm, virDomainDiskDefPtr disk)
+libxlDomainChangeEjectableMedia(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm, virDomainDiskDefPtr
+ disk)
{
virDomainDiskDefPtr origdisk = NULL;
libxl_device_disk x_disk;
@@ -3196,7 +3197,7 @@ libxlDomainChangeEjectableMedia(libxlDomainObjPrivatePtr priv,
return -1;
}
- if (libxlMakeDisk(disk, &x_disk) < 0)
+ if (libxlMakeDisk(driver, disk, &x_disk) < 0)
goto cleanup;
if ((ret = libxl_cdrom_insert(priv->ctx, vm->def->id, &x_disk, NULL)) < 0) {
@@ -3221,8 +3222,9 @@ cleanup:
}
static int
-libxlDomainAttachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
- virDomainObjPtr vm, virDomainDeviceDefPtr dev)
+libxlDomainAttachDeviceDiskLive(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
{
virDomainDiskDefPtr l_disk = dev->data.disk;
libxl_device_disk x_disk;
@@ -3230,7 +3232,7 @@ libxlDomainAttachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
switch (l_disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
- ret = libxlDomainChangeEjectableMedia(priv, vm, l_disk);
+ ret = libxlDomainChangeEjectableMedia(driver, priv, vm, l_disk);
break;
case VIR_DOMAIN_DISK_DEVICE_DISK:
if (l_disk->bus == VIR_DOMAIN_DISK_BUS_XEN) {
@@ -3251,7 +3253,7 @@ libxlDomainAttachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
goto cleanup;
}
- if (libxlMakeDisk(l_disk, &x_disk) < 0)
+ if (libxlMakeDisk(driver, l_disk, &x_disk) < 0)
goto cleanup;
if ((ret = libxl_device_disk_add(priv->ctx, vm->def->id,
@@ -3282,8 +3284,9 @@ cleanup:
}
static int
-libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
- virDomainObjPtr vm, virDomainDeviceDefPtr dev)
+libxlDomainDetachDeviceDiskLive(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
{
virDomainDiskDefPtr l_disk = NULL;
libxl_device_disk x_disk;
@@ -3304,7 +3307,7 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
l_disk = vm->def->disks[i];
- if (libxlMakeDisk(l_disk, &x_disk) < 0)
+ if (libxlMakeDisk(driver, l_disk, &x_disk) < 0)
goto cleanup;
if ((ret = libxl_device_disk_remove(priv->ctx, vm->def->id,
@@ -3336,14 +3339,15 @@ cleanup:
}
static int
-libxlDomainAttachDeviceLive(libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
+libxlDomainAttachDeviceLive(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
{
int ret = -1;
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
- ret = libxlDomainAttachDeviceDiskLive(priv, vm, dev);
+ ret = libxlDomainAttachDeviceDiskLive(driver, priv, vm, dev);
if (!ret)
dev->data.disk = NULL;
break;
@@ -3388,14 +3392,15 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
}
static int
-libxlDomainDetachDeviceLive(libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
+libxlDomainDetachDeviceLive(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
{
int ret = -1;
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
- ret = libxlDomainDetachDeviceDiskLive(priv, vm, dev);
+ ret = libxlDomainDetachDeviceDiskLive(driver, priv, vm, dev);
break;
default:
@@ -3435,8 +3440,9 @@ libxlDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
}
static int
-libxlDomainUpdateDeviceLive(libxlDomainObjPrivatePtr priv,
- virDomainObjPtr vm, virDomainDeviceDefPtr dev)
+libxlDomainUpdateDeviceLive(libxlDriverPrivatePtr driver,
+ libxlDomainObjPrivatePtr priv, virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
{
virDomainDiskDefPtr disk;
int ret = -1;
@@ -3446,7 +3452,7 @@ libxlDomainUpdateDeviceLive(libxlDomainObjPrivatePtr priv,
disk = dev->data.disk;
switch (disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
- ret = libxlDomainChangeEjectableMedia(priv, vm, disk);
+ ret = libxlDomainChangeEjectableMedia(driver, priv, vm, disk);
if (ret == 0)
dev->data.disk = NULL;
break;
@@ -3601,13 +3607,13 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
switch (action) {
case LIBXL_DEVICE_ATTACH:
- ret = libxlDomainAttachDeviceLive(priv, vm, dev);
+ ret = libxlDomainAttachDeviceLive(driver, priv, vm, dev);
break;
case LIBXL_DEVICE_DETACH:
- ret = libxlDomainDetachDeviceLive(priv, vm, dev);
+ ret = libxlDomainDetachDeviceLive(driver, priv, vm, dev);
break;
case LIBXL_DEVICE_UPDATE:
- ret = libxlDomainUpdateDeviceLive(priv, vm, dev);
+ ret = libxlDomainUpdateDeviceLive(driver, priv, vm, dev);
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 12/12] libxl: fix deadlock in libxlReconnectDomain
by Marek Marczykowski
Use virDomainObjListRemoveLocked instead of virDomainObjListRemove, as
driver->domains is already taken by virDomainObjListForEach.
Above deadlock can be triggered when libvirtd is started after some
domain have been started by hand (in which case driver will not find
libvirt-xml domain config).
---
src/libxl/libxl_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b0f0c6a..687190c 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1060,7 +1060,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
out:
libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_UNKNOWN);
if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
+ virDomainObjListRemoveLocked(driver->domains, vm);
else
virObjectUnlock(vm);
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] docs: fix typo when using Kerberos principals
by Eric Blake
Kerberos uses 'primary' or 'key' files (principals), not 'abstract
ideal' (principles). Reported by Jason Meinzer.
Reflow a paragraph to fit in 80 columns in the process.
* docs/auth.html.in: Fix spelling.
---
Pushing under the trivial rule.
docs/auth.html.in | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/docs/auth.html.in b/docs/auth.html.in
index 929afd0..1bd02f2 100644
--- a/docs/auth.html.in
+++ b/docs/auth.html.in
@@ -253,13 +253,15 @@ Plugin "gssapiv2" [loaded], API version: 4
features: WANT_CLIENT_FIRST|PROXY_AUTHENTICATION|NEED_SERVER_FQDN
</pre>
<p>
-Next it is necessary for the administrator of the Kerberos realm to issue a principle
-for the libvirt server. There needs to be one principle per host running the libvirt
-daemon. The principle should be named <code>libvirt/full.hostname(a)KERBEROS.REALM</code>.
-This is typically done by running the <code>kadmin.local</code> command on the Kerberos
-server, though some Kerberos servers have alternate ways of setting up service principles.
-Once created, the principle should be exported to a keytab, copied to the host running
-the libvirt daemon and placed in <code>/etc/libvirt/krb5.tab</code>
+Next it is necessary for the administrator of the Kerberos realm to
+issue a principal for the libvirt server. There needs to be one
+principal per host running the libvirt daemon. The principal should be
+named <code>libvirt/full.hostname(a)KERBEROS.REALM</code>. This is
+typically done by running the <code>kadmin.local</code> command on the
+Kerberos server, though some Kerberos servers have alternate ways of
+setting up service principals. Once created, the principal should be
+exported to a keytab, copied to the host running the libvirt daemon
+and placed in <code>/etc/libvirt/krb5.tab</code>
</p>
<pre>
# kadmin.local
@@ -281,7 +283,7 @@ kadmin.local: quit
</pre>
<p>
Any client application wishing to connect to a Kerberos enabled libvirt server
-merely needs to run <code>kinit</code> to gain a user principle. This may well
+merely needs to run <code>kinit</code> to gain a user principal. This may well
be done automatically when a user logs into a desktop session, if PAM is setup
to authenticate against Kerberos.
</p>
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] Release VM lock before acquiring virDomainObjListPtr lock
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
When removing a VM from the virDomainObjListPtr, we must not
be holding the VM lock while acquiring the list lock. Re-order
code to ensure that we can release the VM lock early.
---
src/conf/domain_conf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5e16ddf..d92e54a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2115,11 +2115,10 @@ void virDomainObjListRemove(virDomainObjListPtr doms,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- virObjectLock(doms);
virUUIDFormat(dom->def->uuid, uuidstr);
-
virObjectUnlock(dom);
+ virObjectLock(doms);
virHashRemoveEntry(doms->objs, uuidstr);
virObjectUnlock(doms);
}
--
1.8.1
11 years, 7 months
[libvirt] (no subject)
by arvind viswanathan
I wanted to check if event loop integration was supported even for remote
applications using libvirt. My application would like to make non-blocking
calls and also recv asynchronous notification remotely. Can some one point
out if its supported.
thanks
11 years, 7 months
[libvirt] [PATCH] maint: update to latest gnulib
by Eric Blake
While this update doesn't address any reported problems in libvirt,
doing a post-release update to latest gnulib makes it easier to
stay in sync with best upstream practices.
* .gnulib: Update to latest.
* bootstrap: Resynchronize.
---
Here's what changed in gnulib:
* .gnulib 819b1c3...076ac82 (58):
> stdalign: doc fix
> stdalign: port to stricter ISO C11
> sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
> check for (erroneous) ftp-upload.gnu.org
> copy-file, rpmatch: fix problems found by cppcheck
> prefix-gnulib-mk: give better diagnostics
> putenv: port to Solaris 10
> mktime: fix configure typo
> regex-tests: skip UTF-8 test on mingw
> tests: make it easier to bypass alarm time in debugger
> regex: port to mingw's recent addition of undeclared alarm
> putenv: avoid compilation warning on mingw
> unistd: don't prevent Tru64 Unix from using gnulib strtod.
> autoupdate
> vasprintf-posix-tests: allow rounding 1.51 to 1.
> vasprintf-posix-tests: allow rounding 1.5 to 1.
> autoupdate
> vasnprintf-posix-tests: allow rounding 1.5 to 1
> bootstrap: port to FreeBSD
> regex: rename remaining __attribute calls to __attribute__.
> execute: Revert last change, but use a different condition.
> execute: drop dead code
> non-recursive-gnulib-prefix-hack: port coreutils 8.21 to HP NonStop
> test-getsockopt: avoid compiler warning
> sys_types: Avoid autoconf warning about gl_SYS_TYPES_H.
> gettext: Update to version 0.18.2.
> maint: restore gendocs.sh execute bit
> regex: merge patches from libc
> putenv: port better to native Windows
> regex: ignore old-style-definition warnings
> getcwd: support coreutils better
> * lib/strtod.c (HAVE_RAW_DECL_STRTOD): Remove; no longer used.
> strtod: support coreutils better
> mountlist: port to HP NonStop
> Fix typo in stdnoreturn documentation.
> extern-inline: avoid compilation error with HP-UX cc
> putenv: fix heap corruption with mixed putenv/_putenv
> autoupdate
> autoupdate
> unsetenv etc.: port to Solaris 11 + GNU Emacs
> secure_getenv: fix C++ declaration typo
> careadlinkat: stop exporting careadlinkatcwd
> extensions: port better to HP-UX
> openpty: fix bug where HAVE_OPENPTY is mistakenly 1
> maint: fix misspelling of MINIX in ChangeLog
> secure_getenv: fix include typo
> secure_getenv: port better to FreeBSD and Solaris
> extensions: port better to MINUX 3, HP-UX, autoheader 2.62
> unistd: avoid namespace pollution on non-glibc systems
> autoupdate
> tmpdir: use secure_getenv
> tempname: use secure_getenv
> secure_getenv: new module
> autoupdate
> getcwd: break fdopendir + save_cwd recursive loop (Bug#13516)
> regex-tests, regex: fix bug: memset undeclared
> regex-tests: fix link errors on older Solaris
> update from texinfo
.gnulib | 2 +-
bootstrap | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/.gnulib b/.gnulib
index 819b1c3..076ac82 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 819b1c38b9abd94d7d1ca2a77bbe16053b75029c
+Subproject commit 076ac82d1d7f4df54630f1b4917b3c14f227f032
diff --git a/bootstrap b/bootstrap
index bee7765..96f1e76 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2013-01-20.16; # UTC
+scriptversion=2013-03-08.16; # UTC
# Bootstrap this package from checked-out sources.
@@ -630,9 +630,13 @@ esac
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
+ case $(sh -c 'echo "$1"' -- a) in
+ a) ignored=--;;
+ *) ignored=ignored;;
+ esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
- -- "$GNULIB_SRCDIR/build-aux/bootstrap" \
+ $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
fi
--
1.8.1.4
11 years, 7 months