[libvirt] [PATCH] Convert libxl driver to Xen 4.2
by Jim Fehlig
Based on a patch originally authored by Daniel De Graaf
http://lists.xen.org/archives/html/xen-devel/2012-05/msg00565.html
This patch converts the Xen libxl driver to support only Xen >= 4.2.
Support for Xen 4.1 libxl is dropped since that version of libxl is
designated 'technology preview' only and is incompatible with Xen 4.2
libxl. Additionally, the default toolstack in Xen 4.1 is still xend,
for which libvirt has a stable, functional driver.
---
V2:
Remove 128 vcpu limit.
Remove split_string_into_string_list() function copied from xen
sources since libvirt now has virStringSplit().
configure.ac | 8 +-
docs/drvxen.html.in | 8 +
libvirt.spec.in | 4 +-
src/libxl/libxl_conf.c | 321 +++++++++---------------------
src/libxl/libxl_conf.h | 16 +-
src/libxl/libxl_driver.c | 488 +++++++++++++++++++++++++++-------------------
6 files changed, 404 insertions(+), 441 deletions(-)
diff --git a/configure.ac b/configure.ac
index c888eb8..a695e52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,16 +718,14 @@ if test "$with_libxl" != "no" ; then
fi
CFLAGS="$CFLAGS $LIBXL_CFLAGS"
LIBS="$LIBS $LIBXL_LIBS"
- AC_CHECK_LIB([xenlight], [libxl_domain_create_new], [
+ AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
with_libxl=yes
- LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenstore -lxenctrl -lxenguest -luuid -lutil -lblktapctl"
+ LIBXL_LIBS="$LIBXL_LIBS -lxenlight"
],[
if test "$with_libxl" = "yes"; then
fail=1
fi
with_libxl=no
- ],[
- -lxenstore -lxenctrl -lxenguest -luuid -lutil -lblktapctl
])
fi
@@ -735,7 +733,7 @@ LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
if test $fail = 1; then
- AC_MSG_ERROR([You must install the libxl Library to compile libxenlight driver with -lxl])
+ AC_MSG_ERROR([You must install the libxl Library from Xen >= 4.2 to compile libxenlight driver with -lxl])
fi
if test "$with_libxl" = "yes"; then
diff --git a/docs/drvxen.html.in b/docs/drvxen.html.in
index 0bca935..06bd911 100644
--- a/docs/drvxen.html.in
+++ b/docs/drvxen.html.in
@@ -53,6 +53,14 @@
the <code>/etc/xen</code> directory. It is important not to place
any other non-config files in this directory.
</li>
+ <li>
+ <strong>libxl</strong>: Starting with Xen 4.2, the legacy XenD/xm
+ toolstack is deprecated in favor of libxl, also commonly called
+ libxenlight. libvirt supports this new Xen toolstack via the
+ libxl driver. If XenD is enabled, the legacy xen driver consisting
+ of the above mentioned channels will be used. If XenD is disabled,
+ the libxl driver will be used.
+ </li>
</ul>
<h2><a name="uri">Connections to Xen driver</a></h2>
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 5b3f4e4..47cb087 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -189,8 +189,8 @@
%endif
%endif
-# Fedora doesn't have new enough Xen for libxl until F16
-%if 0%{?fedora} && 0%{?fedora} < 16
+# Fedora doesn't have new enough Xen for libxl until F18
+%if 0%{?fedora} && 0%{?fedora} < 18
%define with_libxl 0
%endif
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 1c3130b..b8b9ddb 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -36,11 +36,13 @@
#include "virterror_internal.h"
#include "datatypes.h"
#include "virfile.h"
+#include "virstring.h"
#include "memory.h"
#include "uuid.h"
#include "capabilities.h"
#include "libxl_driver.h"
#include "libxl_conf.h"
+#include "libxl_utils.h"
#include "storage_file.h"
@@ -62,7 +64,6 @@ struct guest_arch {
static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x86_64|ia64|powerpc64)(p|be)?";
static regex_t xen_cap_rec;
-
static int
libxlNextFreeVncPort(libxlDriverPrivatePtr driver, int startPort)
{
@@ -360,18 +361,36 @@ libxlMakeCapabilitiesInternal(const char *hostmachine,
}
static int
-libxlMakeDomCreateInfo(virDomainDefPtr def, libxl_domain_create_info *c_info)
+libxlMakeDomCreateInfo(libxlDriverPrivatePtr driver,
+ virDomainDefPtr def,
+ libxl_domain_create_info *c_info)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- libxl_init_create_info(c_info);
+ libxl_domain_create_info_init(c_info);
+
+ if (STREQ(def->os.type, "hvm"))
+ c_info->type = LIBXL_DOMAIN_TYPE_HVM;
+ else
+ c_info->type = LIBXL_DOMAIN_TYPE_PV;
- c_info->hvm = STREQ(def->os.type, "hvm");
if ((c_info->name = strdup(def->name)) == NULL) {
virReportOOMError();
goto error;
}
+ if (def->nseclabels &&
+ def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_STATIC) {
+ if (libxl_flask_context_to_sid(driver->ctx,
+ def->seclabels[0]->label,
+ strlen(def->seclabels[0]->label),
+ &c_info->ssidref)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("libxenlight failed to resolve security label '%s'"),
+ def->seclabels[0]->label);
+ }
+ }
+
virUUIDFormat(def->uuid, uuidstr);
if (libxl_uuid_from_string(&c_info->uuid, uuidstr)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -382,7 +401,7 @@ libxlMakeDomCreateInfo(virDomainDefPtr def, libxl_domain_create_info *c_info)
return 0;
error:
- libxl_domain_create_info_destroy(c_info);
+ libxl_domain_create_info_dispose(c_info);
return -1;
}
@@ -393,26 +412,14 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
int hvm = STREQ(def->os.type, "hvm");
int i;
- /* Currently, libxenlight only supports 32 vcpus per domain.
- * cur_vcpus member of struct libxl_domain_build_info is defined
- * as an int, but its semantic is a bitmap of online vcpus, so
- * only 32 can be represented.
- */
- if (def->maxvcpus > 32 || def->vcpus > 32) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("This version of libxenlight only supports 32 "
- "vcpus per domain"));
- return -1;
- }
+ libxl_domain_build_info_init(b_info);
- libxl_init_build_info(b_info, &d_config->c_info);
-
- b_info->hvm = hvm;
- b_info->max_vcpus = def->maxvcpus;
- if (def->vcpus == 32)
- b_info->cur_vcpus = (uint32_t) -1;
+ if (hvm)
+ libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
else
- b_info->cur_vcpus = (1 << def->vcpus) - 1;
+ libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+ b_info->max_vcpus = def->maxvcpus;
+ libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
if (def->clock.ntimers > 0 &&
def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
switch (def->clock.timers[0]->mode) {
@@ -426,16 +433,20 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
b_info->tsc_mode = 1;
}
}
+ b_info->sched_params.weight = 1000;
b_info->max_memkb = def->mem.max_balloon;
b_info->target_memkb = def->mem.cur_balloon;
if (hvm) {
- b_info->u.hvm.pae = def->features & (1 << VIR_DOMAIN_FEATURE_PAE);
- b_info->u.hvm.apic = def->features & (1 << VIR_DOMAIN_FEATURE_APIC);
- b_info->u.hvm.acpi = def->features & (1 << VIR_DOMAIN_FEATURE_ACPI);
+ libxl_defbool_set(&b_info->u.hvm.pae,
+ def->features & (1 << VIR_DOMAIN_FEATURE_PAE));
+ libxl_defbool_set(&b_info->u.hvm.apic,
+ def->features & (1 << VIR_DOMAIN_FEATURE_APIC));
+ libxl_defbool_set(&b_info->u.hvm.acpi,
+ def->features & (1 << VIR_DOMAIN_FEATURE_ACPI));
for (i = 0; i < def->clock.ntimers; i++) {
if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET &&
def->clock.timers[i]->present == 1) {
- b_info->u.hvm.hpet = 1;
+ libxl_defbool_set(&b_info->u.hvm.hpet, 1);
}
}
@@ -446,7 +457,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
* 256 pages (1MB) per vcpu, plus 1 page per MiB of RAM for the P2M map,
* plus 1 page per MiB of RAM to shadow the resident processes.
*/
- b_info->shadow_memkb = 4 * (256 * b_info->cur_vcpus +
+ b_info->shadow_memkb = 4 * (256 * libxl_bitmap_count_set(&b_info->avail_vcpus) +
2 * (b_info->max_memkb / 1024));
} else {
if (def->os.bootloader) {
@@ -456,10 +467,9 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
}
}
if (def->os.bootloaderArgs) {
- if ((b_info->u.pv.bootloader_args = strdup(def->os.bootloaderArgs)) == NULL) {
- virReportOOMError();
+ if (!(b_info->u.pv.bootloader_args =
+ virStringSplit(def->os.bootloaderArgs, " \t\n", 0)))
goto error;
- }
}
if (def->os.cmdline) {
if ((b_info->u.pv.cmdline = strdup(def->os.cmdline)) == NULL) {
@@ -469,14 +479,14 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
}
if (def->os.kernel) {
/* libxl_init_build_info() sets kernel.path = strdup("hvmloader") */
- VIR_FREE(b_info->kernel.path);
- if ((b_info->kernel.path = strdup(def->os.kernel)) == NULL) {
+ VIR_FREE(b_info->u.pv.kernel);
+ if ((b_info->u.pv.kernel = strdup(def->os.kernel)) == NULL) {
virReportOOMError();
goto error;
}
}
if (def->os.initrd) {
- if ((b_info->u.pv.ramdisk.path = strdup(def->os.initrd)) == NULL) {
+ if ((b_info->u.pv.ramdisk = strdup(def->os.initrd)) == NULL) {
virReportOOMError();
goto error;
}
@@ -486,13 +496,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
return 0;
error:
- libxl_domain_build_info_destroy(b_info);
+ libxl_domain_build_info_dispose(b_info);
return -1;
}
int
-libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
- libxl_device_disk *x_disk)
+libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
{
if (l_disk->src && (x_disk->pdev_path = strdup(l_disk->src)) == NULL) {
virReportOOMError();
@@ -509,22 +518,22 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
STREQ(l_disk->driverName, "tap2")) {
switch (l_disk->format) {
case VIR_STORAGE_FILE_QCOW:
- x_disk->format = DISK_FORMAT_QCOW;
- x_disk->backend = DISK_BACKEND_QDISK;
+ x_disk->format = LIBXL_DISK_FORMAT_QCOW;
+ x_disk->backend = LIBXL_DISK_BACKEND_QDISK;
break;
case VIR_STORAGE_FILE_QCOW2:
- x_disk->format = DISK_FORMAT_QCOW2;
- x_disk->backend = DISK_BACKEND_QDISK;
+ x_disk->format = LIBXL_DISK_FORMAT_QCOW2;
+ x_disk->backend = LIBXL_DISK_BACKEND_QDISK;
break;
case VIR_STORAGE_FILE_VHD:
- x_disk->format = DISK_FORMAT_VHD;
- x_disk->backend = DISK_BACKEND_TAP;
+ x_disk->format = LIBXL_DISK_FORMAT_VHD;
+ x_disk->backend = LIBXL_DISK_BACKEND_TAP;
break;
case VIR_STORAGE_FILE_NONE:
/* No subtype specified, default to raw/tap */
case VIR_STORAGE_FILE_RAW:
- x_disk->format = DISK_FORMAT_RAW;
- x_disk->backend = DISK_BACKEND_TAP;
+ x_disk->format = LIBXL_DISK_FORMAT_RAW;
+ x_disk->backend = LIBXL_DISK_BACKEND_TAP;
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -533,11 +542,11 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
return -1;
}
} else if (STREQ(l_disk->driverName, "file")) {
- x_disk->format = DISK_FORMAT_RAW;
- x_disk->backend = DISK_BACKEND_TAP;
+ x_disk->format = LIBXL_DISK_FORMAT_RAW;
+ x_disk->backend = LIBXL_DISK_BACKEND_TAP;
} else if (STREQ(l_disk->driverName, "phy")) {
- x_disk->format = DISK_FORMAT_RAW;
- x_disk->backend = DISK_BACKEND_PHY;
+ x_disk->format = LIBXL_DISK_FORMAT_RAW;
+ x_disk->backend = LIBXL_DISK_BACKEND_PHY;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight does not support disk driver %s"),
@@ -546,12 +555,12 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
}
} else {
/* No driverName - default to raw/tap?? */
- x_disk->format = DISK_FORMAT_RAW;
- x_disk->backend = DISK_BACKEND_TAP;
+ x_disk->format = LIBXL_DISK_FORMAT_RAW;
+ x_disk->backend = LIBXL_DISK_BACKEND_TAP;
}
- /* How to set unpluggable? */
- x_disk->unpluggable = 1;
+ /* XXX is this right? */
+ x_disk->removable = 1;
x_disk->readwrite = !l_disk->readonly;
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
if (l_disk->transient) {
@@ -560,8 +569,6 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
return -1;
}
- x_disk->domid = def->id;
-
return 0;
}
@@ -579,7 +586,7 @@ libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
}
for (i = 0; i < ndisks; i++) {
- if (libxlMakeDisk(def, l_disks[i], &x_disks[i]) < 0)
+ if (libxlMakeDisk(l_disks[i], &x_disks[i]) < 0)
goto error;
}
@@ -590,19 +597,19 @@ libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
error:
for (i = 0; i < ndisks; i++)
- libxl_device_disk_destroy(&x_disks[i]);
+ libxl_device_disk_dispose(&x_disks[i]);
VIR_FREE(x_disks);
return -1;
}
int
-libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic,
- libxl_device_nic *x_nic)
+libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic)
{
- // TODO: Where is mtu stored?
- //x_nics[i].mtu = 1492;
+ /* TODO: Where is mtu stored?
+ *
+ * x_nics[i].mtu = 1492;
+ */
- x_nic->domid = def->id;
virMacAddrGetRaw(&l_nic->mac, x_nic->mac);
if (l_nic->model && !STREQ(l_nic->model, "netfront")) {
@@ -610,9 +617,9 @@ libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic,
virReportOOMError();
return -1;
}
- x_nic->nictype = NICTYPE_IOEMU;
+ x_nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
} else {
- x_nic->nictype = NICTYPE_VIF;
+ x_nic->nictype = LIBXL_NIC_TYPE_VIF;
}
if (l_nic->ifname && (x_nic->ifname = strdup(l_nic->ifname)) == NULL) {
@@ -659,48 +666,49 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
for (i = 0; i < nnics; i++) {
x_nics[i].devid = i;
- if (libxlMakeNic(def, l_nics[i], &x_nics[i]))
+ if (libxlMakeNic(l_nics[i], &x_nics[i]))
goto error;
}
- d_config->vifs = x_nics;
- d_config->num_vifs = nnics;
+ d_config->nics = x_nics;
+ d_config->num_nics = nnics;
return 0;
error:
for (i = 0; i < nnics; i++)
- libxl_device_nic_destroy(&x_nics[i]);
+ libxl_device_nic_dispose(&x_nics[i]);
VIR_FREE(x_nics);
return -1;
}
int
-libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
- virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb)
+libxlMakeVfb(libxlDriverPrivatePtr driver,
+ virDomainGraphicsDefPtr l_vfb,
+ libxl_device_vfb *x_vfb)
{
int port;
const char *listenAddr;
switch (l_vfb->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
- x_vfb->sdl = 1;
+ libxl_defbool_set(&x_vfb->sdl.enable, 1);
if (l_vfb->data.sdl.display &&
- (x_vfb->display = strdup(l_vfb->data.sdl.display)) == NULL) {
+ (x_vfb->sdl.display = strdup(l_vfb->data.sdl.display)) == NULL) {
virReportOOMError();
return -1;
}
if (l_vfb->data.sdl.xauth &&
- (x_vfb->xauthority =
+ (x_vfb->sdl.xauthority =
strdup(l_vfb->data.sdl.xauth)) == NULL) {
virReportOOMError();
return -1;
}
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
- x_vfb->vnc = 1;
+ libxl_defbool_set(&x_vfb->vnc.enable, 1);
/* driver handles selection of free port */
- x_vfb->vncunused = 0;
+ libxl_defbool_set(&x_vfb->vnc.findunused, 0);
if (l_vfb->data.vnc.autoport) {
port = libxlNextFreeVncPort(driver, LIBXL_VNC_PORT_MIN);
if (port < 0) {
@@ -710,13 +718,13 @@ libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
}
l_vfb->data.vnc.port = port;
}
- x_vfb->vncdisplay = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN;
+ 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->vnclisten);
- if ((x_vfb->vnclisten = strdup(listenAddr)) == NULL) {
+ VIR_FREE(x_vfb->vnc.listen);
+ if ((x_vfb->vnc.listen = strdup(listenAddr)) == NULL) {
virReportOOMError();
return -1;
}
@@ -729,13 +737,14 @@ libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
}
break;
}
- x_vfb->domid = def->id;
+
return 0;
}
static int
libxlMakeVfbList(libxlDriverPrivatePtr driver,
- virDomainDefPtr def, libxl_domain_config *d_config)
+ virDomainDefPtr def,
+ libxl_domain_config *d_config)
{
virDomainGraphicsDefPtr *l_vfbs = def->graphics;
int nvfbs = def->ngraphics;
@@ -757,10 +766,10 @@ libxlMakeVfbList(libxlDriverPrivatePtr driver,
}
for (i = 0; i < nvfbs; i++) {
- libxl_device_vfb_init(&x_vfbs[i], i);
- libxl_device_vkb_init(&x_vkbs[i], i);
+ libxl_device_vfb_init(&x_vfbs[i]);
+ libxl_device_vkb_init(&x_vkbs[i]);
- if (libxlMakeVfb(driver, def, l_vfbs[i], &x_vfbs[i]) < 0)
+ if (libxlMakeVfb(driver, l_vfbs[i], &x_vfbs[i]) < 0)
goto error;
}
@@ -772,148 +781,14 @@ libxlMakeVfbList(libxlDriverPrivatePtr driver,
error:
for (i = 0; i < nvfbs; i++) {
- libxl_device_vfb_destroy(&x_vfbs[i]);
- libxl_device_vkb_destroy(&x_vkbs[i]);
+ libxl_device_vfb_dispose(&x_vfbs[i]);
+ libxl_device_vkb_dispose(&x_vkbs[i]);
}
VIR_FREE(x_vfbs);
VIR_FREE(x_vkbs);
return -1;
}
-static int
-libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
-{
- const char *type = virDomainChrTypeToString(def->source.type);
-
- if (!type) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("unexpected chr device type"));
- return -1;
- }
-
- switch (def->source.type) {
- case VIR_DOMAIN_CHR_TYPE_NULL:
- case VIR_DOMAIN_CHR_TYPE_STDIO:
- case VIR_DOMAIN_CHR_TYPE_VC:
- case VIR_DOMAIN_CHR_TYPE_PTY:
- if (virAsprintf(buf, "%s", type) < 0) {
- virReportOOMError();
- return -1;
- }
- break;
-
- case VIR_DOMAIN_CHR_TYPE_FILE:
- case VIR_DOMAIN_CHR_TYPE_PIPE:
- if (virAsprintf(buf, "%s:%s", type,
- def->source.data.file.path) < 0) {
- virReportOOMError();
- return -1;
- }
- break;
-
- case VIR_DOMAIN_CHR_TYPE_DEV:
- if (virAsprintf(buf, "%s", def->source.data.file.path) < 0) {
- virReportOOMError();
- return -1;
- }
- break;
- }
-
- return 0;
-}
-
-static int
-libxlMakeDeviceModelInfo(virDomainDefPtr def, libxl_domain_config *d_config)
-{
- libxl_device_model_info *dm_info = &d_config->dm_info;
- int i;
- char b_order[VIR_DOMAIN_BOOT_LAST+1];
-
- libxl_init_dm_info(dm_info, &d_config->c_info, &d_config->b_info);
-
- if (d_config->b_info.hvm) {
- /* HVM-specific device model info */
- dm_info->type = XENFV;
- if (def->os.nBootDevs > 0) {
- VIR_FREE(dm_info->boot);
- for (i = 0; i < def->os.nBootDevs; i++) {
- switch (def->os.bootDevs[i]) {
- case VIR_DOMAIN_BOOT_FLOPPY:
- b_order[i] = 'a';
- break;
- default:
- case VIR_DOMAIN_BOOT_DISK:
- b_order[i] = 'c';
- break;
- case VIR_DOMAIN_BOOT_CDROM:
- b_order[i] = 'd';
- break;
- case VIR_DOMAIN_BOOT_NET:
- b_order[i] = 'n';
- break;
- }
- }
- b_order[def->os.nBootDevs] = '\0';
- if ((dm_info->boot = strdup(b_order)) == NULL) {
- virReportOOMError();
- goto error;
- }
- }
- if (def->serials &&
- (libxlMakeChrdevStr(def->serials[0], &dm_info->serial) < 0))
- goto error;
- } else {
- /* PV-specific device model info */
- dm_info->type = XENPV;
- }
-
- /* Build qemu graphics options from previously parsed vfb */
- if (d_config->num_vfbs > 0) {
- if (d_config->vfbs[0].vnc) {
- dm_info->vnc = 1;
- /* driver handles selection of free port */
- dm_info->vncunused = 0;
- if (d_config->vfbs[0].vnclisten) {
- VIR_FREE(dm_info->vnclisten);
- if ((dm_info->vnclisten =
- strdup(d_config->vfbs[0].vnclisten)) == NULL) {
- virReportOOMError();
- goto error;
- }
- }
- if (d_config->vfbs[0].keymap &&
- (dm_info->keymap = strdup(d_config->vfbs[0].keymap)) == NULL) {
- virReportOOMError();
- goto error;
- }
- dm_info->vncdisplay = d_config->vfbs[0].vncdisplay;
- if (d_config->vfbs[0].vncpasswd &&
- (dm_info->vncpasswd =
- strdup(d_config->vfbs[0].vncpasswd)) == NULL) {
- virReportOOMError();
- goto error;
- }
- } else if (d_config->vfbs[0].sdl) {
- dm_info->sdl = 1;
- dm_info->vnc = 0;
- }
- } else if (d_config->num_vfbs == 0) {
- dm_info->nographic = 1;
- dm_info->vnc = 0;
- }
-
- // TODO
- //dm_info->usb = ;
- //dm_info->usbdevice = ;
- //dm_info->soundhw = ;
-
- return 0;
-
-error:
- libxl_device_model_info_destroy(dm_info);
- return -1;
-}
-
virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx)
{
@@ -947,7 +822,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
virDomainDefPtr def, libxl_domain_config *d_config)
{
- if (libxlMakeDomCreateInfo(def, &d_config->c_info) < 0)
+ if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
return -1;
if (libxlMakeDomBuildInfo(def, d_config) < 0) {
@@ -966,10 +841,6 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
goto error;
}
- if (libxlMakeDeviceModelInfo(def, d_config) < 0) {
- goto error;
- }
-
d_config->on_reboot = def->onReboot;
d_config->on_poweroff = def->onPoweroff;
d_config->on_crash = def->onCrash;
@@ -977,6 +848,6 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
return 0;
error:
- libxl_domain_config_destroy(d_config);
+ libxl_domain_config_dispose(d_config);
return -1;
}
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 56bf85c..8b5a9e9 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -58,7 +58,7 @@ struct _libxlDriverPrivate {
FILE *logger_file;
xentoollog_logger *logger;
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
- libxl_ctx ctx;
+ libxl_ctx *ctx;
virBitmapPtr reservedVNCPorts;
virDomainObjList domains;
@@ -77,10 +77,8 @@ typedef struct _libxlDomainObjPrivate libxlDomainObjPrivate;
typedef libxlDomainObjPrivate *libxlDomainObjPrivatePtr;
struct _libxlDomainObjPrivate {
/* per domain libxl ctx */
- libxl_ctx ctx;
- libxl_waiter *dWaiter;
- int waiterFD;
- int eventHdl;
+ libxl_ctx *ctx;
+ libxl_evgen_domain_death *deathW;
};
# define LIBXL_SAVE_MAGIC "libvirt-xml\n \0 \r"
@@ -100,13 +98,11 @@ virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx);
int
-libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_dev,
- libxl_device_disk *x_dev);
+libxlMakeDisk(virDomainDiskDefPtr l_dev, libxl_device_disk *x_dev);
int
-libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic,
- libxl_device_nic *x_nic);
+libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic);
int
-libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+libxlMakeVfb(libxlDriverPrivatePtr driver,
virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb);
int
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ae4451a..44d0781 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -40,6 +40,7 @@
#include "memory.h"
#include "uuid.h"
#include "command.h"
+#include "libxl.h"
#include "libxl_driver.h"
#include "libxl_conf.h"
#include "xen_xm.h"
@@ -59,6 +60,19 @@
/* Number of Xen scheduler parameters */
#define XEN_SCHED_CREDIT_NPARAM 2
+struct libxlOSEventHookFDInfo {
+ libxlDomainObjPrivatePtr priv;
+ void *xl_priv;
+ int watch;
+};
+
+struct libxlOSEventHookTimerInfo {
+ libxlDomainObjPrivatePtr priv;
+ void *xl_priv;
+ int id;
+};
+
+
static void libxlDomainManagedSaveLoad(void *payload,
const void *n ATTRIBUTE_UNUSED,
void *opaque);
@@ -84,6 +98,163 @@ libxlDriverUnlock(libxlDriverPrivatePtr driver)
virMutexUnlock(&driver->lock);
}
+
+static void libxlFDEventCallback(int watch ATTRIBUTE_UNUSED,
+ int fd,
+ int vir_events,
+ void *fdinfo)
+{
+ struct libxlOSEventHookFDInfo *info = fdinfo;
+ int events = 0;
+
+ if (vir_events & VIR_EVENT_HANDLE_READABLE)
+ events |= POLLIN;
+ if (vir_events & VIR_EVENT_HANDLE_WRITABLE)
+ events |= POLLOUT;
+ if (vir_events & VIR_EVENT_HANDLE_ERROR)
+ events |= POLLERR;
+ if (vir_events & VIR_EVENT_HANDLE_HANGUP)
+ events |= POLLHUP;
+
+ libxl_osevent_occurred_fd(info->priv->ctx, info->xl_priv, fd, 0, events);
+}
+
+static void libxlFreeFDInfo(void *obj)
+{
+ VIR_FREE(obj);
+}
+
+static int libxlFDRegisterEventHook(void *priv, int fd, void **hndp,
+ short events, void *xl_priv)
+{
+ int vir_events = VIR_EVENT_HANDLE_ERROR;
+ struct libxlOSEventHookFDInfo *fdinfo;
+
+ if (VIR_ALLOC(fdinfo) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ fdinfo->priv = priv;
+ fdinfo->xl_priv = xl_priv;
+ *hndp = fdinfo;
+
+ if (events & POLLIN)
+ vir_events |= VIR_EVENT_HANDLE_READABLE;
+ if (events & POLLOUT)
+ vir_events |= VIR_EVENT_HANDLE_WRITABLE;
+ fdinfo->watch = virEventAddHandle(fd, vir_events, libxlFDEventCallback,
+ fdinfo, libxlFreeFDInfo);
+ if (fdinfo->watch < 0) {
+ VIR_FREE(fdinfo);
+ return fdinfo->watch;
+ }
+
+ return 0;
+}
+
+static int libxlFDModifyEventHook(void *priv ATTRIBUTE_UNUSED,
+ int fd ATTRIBUTE_UNUSED,
+ void **hndp,
+ short events)
+{
+ struct libxlOSEventHookFDInfo *fdinfo = *hndp;
+ int vir_events = VIR_EVENT_HANDLE_ERROR;
+
+ if (events & POLLIN)
+ vir_events |= VIR_EVENT_HANDLE_READABLE;
+ if (events & POLLOUT)
+ vir_events |= VIR_EVENT_HANDLE_WRITABLE;
+
+ virEventUpdateHandle(fdinfo->watch, vir_events);
+ return 0;
+}
+
+static void libxlFDDeregisterEventHook(void *priv ATTRIBUTE_UNUSED,
+ int fd ATTRIBUTE_UNUSED,
+ void *hnd)
+{
+ struct libxlOSEventHookFDInfo *fdinfo = hnd;
+
+ virEventRemoveHandle(fdinfo->watch);
+}
+
+
+static void libxlTimerCallback(int timer ATTRIBUTE_UNUSED, void *timer_v)
+{
+ struct libxlOSEventHookTimerInfo *timer_info = timer_v;
+
+ libxl_osevent_occurred_timeout(timer_info->priv->ctx, timer_info->xl_priv);
+}
+
+static void libxlTimerInfoFree(void* obj)
+{
+ VIR_FREE(obj);
+}
+
+static int libxlTimeoutRegisterEventHook(void *priv,
+ void **hndp,
+ struct timeval abs_t,
+ void *for_libxl)
+{
+ struct timeval now;
+ struct libxlOSEventHookTimerInfo *timer_info;
+ int timeout, timer_id;
+
+ if (VIR_ALLOC(timer_info) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ gettimeofday(&now, NULL);
+ timeout = (abs_t.tv_usec - now.tv_usec) / 1000;
+ timeout += (abs_t.tv_sec - now.tv_sec) * 1000;
+ timer_id = virEventAddTimeout(timeout, libxlTimerCallback,
+ timer_info, libxlTimerInfoFree);
+ if (timer_id < 0) {
+ VIR_FREE(timer_info);
+ return timer_id;
+ }
+
+ timer_info->priv = priv;
+ timer_info->xl_priv = for_libxl;
+ timer_info->id = timer_id;
+ *hndp = timer_info;
+ return 0;
+}
+
+static int libxlTimeoutModifyEventHook(void *priv ATTRIBUTE_UNUSED,
+ void **hndp,
+ struct timeval abs_t)
+{
+ struct timeval now;
+ int timeout;
+ struct libxlOSEventHookTimerInfo *timer_info = *hndp;
+
+ gettimeofday(&now, NULL);
+ timeout = (abs_t.tv_usec - now.tv_usec) / 1000;
+ timeout += (abs_t.tv_sec - now.tv_sec) * 1000;
+ virEventUpdateTimeout(timer_info->id, timeout);
+ return 0;
+}
+
+static void libxlTimeoutDeregisterEventHook(void *priv ATTRIBUTE_UNUSED,
+ void *hnd)
+{
+ struct libxlOSEventHookTimerInfo *timer_info = hnd;
+
+ virEventRemoveTimeout(timer_info->id);
+}
+
+static const libxl_osevent_hooks libxl_event_callbacks = {
+ .fd_register = libxlFDRegisterEventHook,
+ .fd_modify = libxlFDModifyEventHook,
+ .fd_deregister = libxlFDDeregisterEventHook,
+ .timeout_register = libxlTimeoutRegisterEventHook,
+ .timeout_modify = libxlTimeoutModifyEventHook,
+ .timeout_deregister = libxlTimeoutDeregisterEventHook,
+};
+
static void *
libxlDomainObjPrivateAlloc(void)
{
@@ -92,9 +263,9 @@ libxlDomainObjPrivateAlloc(void)
if (VIR_ALLOC(priv) < 0)
return NULL;
- libxl_ctx_init(&priv->ctx, LIBXL_VERSION, libxl_driver->logger);
- priv->waiterFD = -1;
- priv->eventHdl = -1;
+ libxl_ctx_alloc(&priv->ctx, LIBXL_VERSION, 0, libxl_driver->logger);
+ priv->deathW = NULL;
+ libxl_osevent_register_hooks(priv->ctx, &libxl_event_callbacks, priv);
return priv;
}
@@ -104,16 +275,12 @@ libxlDomainObjPrivateFree(void *data)
{
libxlDomainObjPrivatePtr priv = data;
- if (priv->eventHdl >= 0)
- virEventRemoveHandle(priv->eventHdl);
-
- if (priv->dWaiter) {
- libxl_stop_waiting(&priv->ctx, priv->dWaiter);
- libxl_free_waiter(priv->dWaiter);
- VIR_FREE(priv->dWaiter);
+ if (priv->deathW) {
+ libxl_evdisable_domain_death(priv->ctx, priv->deathW);
+ VIR_FREE(priv->deathW);
}
- libxl_ctx_free(&priv->ctx);
+ libxl_ctx_free(priv->ctx);
VIR_FREE(priv);
}
@@ -125,17 +292,6 @@ libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
virDomainEventStateQueue(driver->domainEventState, event);
}
-/*
- * Remove reference to domain object.
- */
-static void
-libxlDomainObjUnref(void *data)
-{
- virDomainObjPtr vm = data;
-
- virObjectUnref(vm);
-}
-
static void
libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
void *opaque)
@@ -166,13 +322,13 @@ libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
const libxl_version_info* ver_info;
struct utsname utsname;
- if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
+ if (libxl_get_physinfo(driver->ctx, &phy_info)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_physinfo_info failed"));
return -1;
}
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ if ((ver_info = libxl_get_version_info(driver->ctx)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_version_info failed"));
return -1;
@@ -296,15 +452,9 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
char *file;
int i;
- if (priv->eventHdl >= 0) {
- virEventRemoveHandle(priv->eventHdl);
- priv->eventHdl = -1;
- }
-
- if (priv->dWaiter) {
- libxl_stop_waiting(&priv->ctx, priv->dWaiter);
- libxl_free_waiter(priv->dWaiter);
- VIR_FREE(priv->dWaiter);
+ if (priv->deathW) {
+ libxl_evdisable_domain_death(priv->ctx, priv->deathW);
+ priv->deathW = NULL;
}
if (vm->persistent) {
@@ -355,12 +505,11 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
static int
libxlVmReap(libxlDriverPrivatePtr driver,
virDomainObjPtr vm,
- int force,
virDomainShutoffReason reason)
{
libxlDomainObjPrivatePtr priv = vm->privateData;
- if (libxl_domain_destroy(&priv->ctx, vm->def->id, force) < 0) {
+ if (libxl_domain_destroy(priv->ctx, vm->def->id, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to cleanup domain %d"), vm->def->id);
return -1;
@@ -373,56 +522,26 @@ libxlVmReap(libxlDriverPrivatePtr driver,
/*
* Handle previously registered event notification from libxenlight
*/
-static void libxlEventHandler(int watch,
- int fd,
- int events,
- void *data)
+static void libxlEventHandler(void *data, const libxl_event *event)
{
libxlDriverPrivatePtr driver = libxl_driver;
virDomainObjPtr vm = data;
- libxlDomainObjPrivatePtr priv;
virDomainEventPtr dom_event = NULL;
- libxl_event event;
- libxl_dominfo info;
libxlDriverLock(driver);
virDomainObjLock(vm);
libxlDriverUnlock(driver);
- priv = vm->privateData;
-
- memset(&event, 0, sizeof(event));
- memset(&info, 0, sizeof(info));
-
- if (priv->waiterFD != fd || priv->eventHdl != watch) {
- virEventRemoveHandle(watch);
- priv->eventHdl = -1;
- goto cleanup;
- }
-
- if (!(events & VIR_EVENT_HANDLE_READABLE))
- goto cleanup;
-
- if (libxl_get_event(&priv->ctx, &event))
- goto cleanup;
-
- if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
+ if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN) {
virDomainShutoffReason reason;
- /* libxl_event_get_domain_death_info returns 1 if death
- * event was for this domid */
- if (libxl_event_get_domain_death_info(&priv->ctx,
- vm->def->id,
- &event,
- &info) != 1)
+ if (event->domid != vm->def->id)
goto cleanup;
- virEventRemoveHandle(watch);
- priv->eventHdl = -1;
- switch (info.shutdown_reason) {
- case SHUTDOWN_poweroff:
- case SHUTDOWN_crash:
- if (info.shutdown_reason == SHUTDOWN_crash) {
+ switch (event->u.domain_shutdown.shutdown_reason) {
+ case LIBXL_SHUTDOWN_REASON_POWEROFF:
+ case LIBXL_SHUTDOWN_REASON_CRASH:
+ if (event->u.domain_shutdown.shutdown_reason == LIBXL_SHUTDOWN_REASON_CRASH) {
dom_event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_CRASHED);
@@ -430,18 +549,18 @@ static void libxlEventHandler(int watch,
} else {
reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
}
- libxlVmReap(driver, vm, 0, reason);
+ libxlVmReap(driver, vm, reason);
if (!vm->persistent) {
virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
}
break;
- case SHUTDOWN_reboot:
- libxlVmReap(driver, vm, 0, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+ case LIBXL_SHUTDOWN_REASON_REBOOT:
+ libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
libxlVmStart(driver, vm, 0, -1);
break;
default:
- VIR_INFO("Unhandled shutdown_reason %d", info.shutdown_reason);
+ VIR_INFO("Unhandled shutdown_reason %d", event->u.domain_shutdown.shutdown_reason);
break;
}
}
@@ -454,9 +573,14 @@ cleanup:
libxlDomainEventQueue(driver, dom_event);
libxlDriverUnlock(driver);
}
- libxl_free_event(&event);
}
+static const struct libxl_event_hooks ev_hooks = {
+ .event_occurs_mask = LIBXL_EVENTMASK_ALL,
+ .event_occurs = libxlEventHandler,
+ .disaster = NULL,
+};
+
/*
* Register domain events with libxenlight and insert event handles
* in libvirt's event loop.
@@ -465,40 +589,18 @@ static int
libxlCreateDomEvents(virDomainObjPtr vm)
{
libxlDomainObjPrivatePtr priv = vm->privateData;
- int fd;
- if (VIR_ALLOC(priv->dWaiter) < 0) {
- virReportOOMError();
- return -1;
- }
-
- if (libxl_wait_for_domain_death(&priv->ctx, vm->def->id, priv->dWaiter))
- goto error;
-
- libxl_get_wait_fd(&priv->ctx, &fd);
- if (fd < 0)
- goto error;
+ libxl_event_register_callbacks(priv->ctx, &ev_hooks, vm);
- priv->waiterFD = fd;
- /* Add a reference to the domain object while it is injected in
- * the event loop.
- */
- virObjectRef(vm);
- if ((priv->eventHdl = virEventAddHandle(
- fd,
- VIR_EVENT_HANDLE_READABLE | VIR_EVENT_HANDLE_ERROR,
- libxlEventHandler,
- vm, libxlDomainObjUnref)) < 0) {
- virObjectUnref(vm);
+ if (libxl_evenable_domain_death(priv->ctx, vm->def->id, 0, &priv->deathW))
goto error;
- }
return 0;
error:
- libxl_free_waiter(priv->dWaiter);
- VIR_FREE(priv->dWaiter);
- priv->eventHdl = -1;
+ if (priv->deathW)
+ libxl_evdisable_domain_death(priv->ctx, priv->deathW);
+ VIR_FREE(priv->deathW);
return -1;
}
@@ -507,7 +609,7 @@ libxlDomainSetVcpuAffinites(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
{
libxlDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
- libxl_cpumap map;
+ libxl_bitmap map;
uint8_t *cpumask = NULL;
uint8_t *cpumap = NULL;
virNodeInfo nodeinfo;
@@ -539,7 +641,7 @@ libxlDomainSetVcpuAffinites(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
map.size = cpumaplen;
map.map = cpumap;
- if (libxl_set_vcpuaffinity(&priv->ctx, def->id, vcpu, &map) != 0) {
+ if (libxl_set_vcpuaffinity(priv->ctx, def->id, vcpu, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
@@ -565,11 +667,10 @@ libxlFreeMem(libxlDomainObjPrivatePtr priv, libxl_domain_config *d_config)
int tries = 3;
int wait_secs = 10;
- if ((ret = libxl_domain_need_memory(&priv->ctx, &d_config->b_info,
- &d_config->dm_info,
+ if ((ret = libxl_domain_need_memory(priv->ctx, &d_config->b_info,
&needed_mem)) >= 0) {
for (i = 0; i < tries; ++i) {
- if ((ret = libxl_get_free_memory(&priv->ctx, &free_mem)) < 0)
+ if ((ret = libxl_get_free_memory(priv->ctx, &free_mem)) < 0)
break;
if (free_mem >= needed_mem) {
@@ -577,17 +678,17 @@ libxlFreeMem(libxlDomainObjPrivatePtr priv, libxl_domain_config *d_config)
break;
}
- if ((ret = libxl_set_memory_target(&priv->ctx, 0,
+ if ((ret = libxl_set_memory_target(priv->ctx, 0,
free_mem - needed_mem,
/* relative */ 1, 0)) < 0)
break;
- ret = libxl_wait_for_free_memory(&priv->ctx, 0, needed_mem,
+ ret = libxl_wait_for_free_memory(priv->ctx, 0, needed_mem,
wait_secs);
if (ret == 0 || ret != ERROR_NOMEM)
break;
- if ((ret = libxl_wait_for_memory_target(&priv->ctx, 0, 1)) < 0)
+ if ((ret = libxl_wait_for_memory_target(priv->ctx, 0, 1)) < 0)
break;
}
}
@@ -613,7 +714,6 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
char *dom_xml = NULL;
char *managed_save_path = NULL;
int managed_save_fd = -1;
- pid_t child_console_pid = -1;
libxlDomainObjPrivatePtr priv = vm->privateData;
/* If there is a managed saved state restore it instead of starting
@@ -657,7 +757,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
VIR_FREE(managed_save_path);
}
- memset(&d_config, 0, sizeof(d_config));
+ libxl_domain_config_init(&d_config);
if (libxlBuildDomainConfig(driver, vm->def, &d_config) < 0)
return -1;
@@ -669,13 +769,14 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
goto error;
}
+ /* use as synchronous operations => ao_how = NULL and no intermediate reports => ao_progress = NULL */
+
if (restore_fd < 0)
- ret = libxl_domain_create_new(&priv->ctx, &d_config,
- NULL, &child_console_pid, &domid);
+ ret = libxl_domain_create_new(priv->ctx, &d_config,
+ &domid, NULL, NULL);
else
- ret = libxl_domain_create_restore(&priv->ctx, &d_config, NULL,
- &child_console_pid, &domid,
- restore_fd);
+ ret = libxl_domain_create_restore(priv->ctx, &d_config, &domid,
+ restore_fd, NULL, NULL);
if (ret) {
if (restore_fd < 0)
@@ -693,7 +794,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
if ((dom_xml = virDomainDefFormat(vm->def, 0)) == NULL)
goto error;
- if (libxl_userdata_store(&priv->ctx, domid, "libvirt-xml",
+ if (libxl_userdata_store(priv->ctx, domid, "libvirt-xml",
(uint8_t *)dom_xml, strlen(dom_xml) + 1)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxenlight failed to store userdata"));
@@ -707,7 +808,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
goto error;
if (!start_paused) {
- libxl_domain_unpause(&priv->ctx, domid);
+ libxl_domain_unpause(priv->ctx, domid);
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
} else {
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER);
@@ -723,18 +824,18 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
VIR_DOMAIN_EVENT_STARTED_RESTORED);
libxlDomainEventQueue(driver, event);
- libxl_domain_config_destroy(&d_config);
+ libxl_domain_config_dispose(&d_config);
VIR_FREE(dom_xml);
VIR_FORCE_CLOSE(managed_save_fd);
return 0;
error:
if (domid > 0) {
- libxl_domain_destroy(&priv->ctx, domid, 0);
+ libxl_domain_destroy(priv->ctx, domid, NULL);
vm->def->id = -1;
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_FAILED);
}
- libxl_domain_config_destroy(&d_config);
+ libxl_domain_config_dispose(&d_config);
VIR_FREE(dom_xml);
VIR_FREE(managed_save_path);
virDomainDefFree(def);
@@ -762,7 +863,7 @@ libxlReconnectDomain(void *payload,
virDomainObjLock(vm);
/* Does domain still exist? */
- rc = libxl_domain_info(&driver->ctx, &d_info, vm->def->id);
+ rc = libxl_domain_info(driver->ctx, &d_info, vm->def->id);
if (rc == ERROR_INVAL) {
goto out;
} else if (rc != 0) {
@@ -772,7 +873,7 @@ libxlReconnectDomain(void *payload,
}
/* Is this a domain that was under libvirt control? */
- if (libxl_userdata_retrieve(&driver->ctx, vm->def->id,
+ if (libxl_userdata_retrieve(driver->ctx, vm->def->id,
"libvirt-xml", &data, &len)) {
VIR_DEBUG("libxl_userdata_retrieve failed, ignoring domain %d", vm->def->id);
goto out;
@@ -810,7 +911,7 @@ libxlShutdown(void)
libxlDriverLock(libxl_driver);
virCapabilitiesFree(libxl_driver->caps);
virDomainObjListDeinit(&libxl_driver->domains);
- libxl_ctx_free(&libxl_driver->ctx);
+ libxl_ctx_free(libxl_driver->ctx);
xtl_logger_destroy(libxl_driver->logger);
if (libxl_driver->logger_file)
VIR_FORCE_FCLOSE(libxl_driver->logger_file);
@@ -943,14 +1044,14 @@ libxlStartup(bool privileged) {
goto fail;
}
- if (libxl_ctx_init(&libxl_driver->ctx,
- LIBXL_VERSION,
+ if (libxl_ctx_alloc(&libxl_driver->ctx,
+ LIBXL_VERSION, 0,
libxl_driver->logger)) {
VIR_INFO("cannot initialize libxenlight context, probably not running in a Xen Dom0, disabling driver");
goto fail;
}
- if ((ver_info = libxl_get_version_info(&libxl_driver->ctx)) == NULL) {
+ if ((ver_info = libxl_get_version_info(libxl_driver->ctx)) == NULL) {
VIR_INFO("cannot version information from libxenlight, disabling driver");
goto fail;
}
@@ -958,7 +1059,7 @@ libxlStartup(bool privileged) {
(ver_info->xen_version_minor * 1000);
if ((libxl_driver->caps =
- libxlMakeCapabilities(&libxl_driver->ctx)) == NULL) {
+ libxlMakeCapabilities(libxl_driver->ctx)) == NULL) {
VIR_ERROR(_("cannot create capabilities for libxenlight"));
goto error;
}
@@ -1115,7 +1216,7 @@ libxlGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
int ret;
libxlDriverPrivatePtr driver = conn->privateData;
- ret = libxl_get_max_cpus(&driver->ctx);
+ ret = libxl_get_max_cpus(driver->ctx);
/* libxl_get_max_cpus() will return 0 if there were any failures,
e.g. xc_physinfo() failing */
if (ret == 0)
@@ -1320,7 +1421,7 @@ libxlDomainSuspend(virDomainPtr dom)
priv = vm->privateData;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
- if (libxl_domain_pause(&priv->ctx, dom->id) != 0) {
+ if (libxl_domain_pause(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to suspend domain '%d' with libxenlight"),
dom->id);
@@ -1379,7 +1480,7 @@ libxlDomainResume(virDomainPtr dom)
priv = vm->privateData;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
- if (libxl_domain_unpause(&priv->ctx, dom->id) != 0) {
+ if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to resume domain '%d' with libxenlight"),
dom->id);
@@ -1436,7 +1537,7 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
}
priv = vm->privateData;
- if (libxl_domain_shutdown(&priv->ctx, dom->id, LIBXL_DOM_REQ_POWEROFF) != 0) {
+ if (libxl_domain_shutdown(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to shutdown domain '%d' with libxenlight"),
dom->id);
@@ -1489,7 +1590,7 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
}
priv = vm->privateData;
- if (libxl_domain_shutdown(&priv->ctx, dom->id, LIBXL_DOM_REQ_REBOOT) != 0) {
+ if (libxl_domain_reboot(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to reboot domain '%d' with libxenlight"),
dom->id);
@@ -1534,7 +1635,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
event = virDomainEventNewFromObj(vm,VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
- if (libxlVmReap(driver, vm, 1, VIR_DOMAIN_SHUTOFF_DESTROYED) != 0) {
+ if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), dom->id);
goto cleanup;
@@ -1672,7 +1773,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_MEM_LIVE) {
priv = vm->privateData;
- if (libxl_domain_setmaxmem(&priv->ctx, dom->id, newmem) < 0) {
+ if (libxl_domain_setmaxmem(priv->ctx, dom->id, newmem) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set maximum memory for domain '%d'"
" with libxenlight"), dom->id);
@@ -1701,7 +1802,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_MEM_LIVE) {
priv = vm->privateData;
- if (libxl_set_memory_target(&priv->ctx, dom->id, newmem, 0,
+ if (libxl_set_memory_target(priv->ctx, dom->id, newmem, 0,
/* force */ 1) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set memory for domain '%d'"
@@ -1761,7 +1862,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
info->memory = vm->def->mem.cur_balloon;
info->maxMem = vm->def->mem.max_balloon;
} else {
- if (libxl_domain_info(&driver->ctx, &d_info, dom->id) != 0) {
+ if (libxl_domain_info(driver->ctx, &d_info, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxl_domain_info failed for domain '%d'"), dom->id);
goto cleanup;
@@ -1861,7 +1962,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
goto cleanup;
}
- if (libxl_domain_suspend(&priv->ctx, NULL, vm->def->id, fd) != 0) {
+ if (libxl_domain_suspend(priv->ctx, vm->def->id, fd, 0, NULL) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to save domain '%d' with libxenlight"),
vm->def->id);
@@ -1871,7 +1972,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_SAVED);
- if (libxlVmReap(driver, vm, 1, VIR_DOMAIN_SHUTOFF_SAVED) != 0) {
+ if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), vm->def->id);
goto cleanup;
@@ -2028,7 +2129,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
if (!(flags & VIR_DUMP_LIVE) &&
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
- if (libxl_domain_pause(&priv->ctx, dom->id) != 0) {
+ if (libxl_domain_pause(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Before dumping core, failed to suspend domain '%d'"
" with libxenlight"),
@@ -2039,7 +2140,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
paused = true;
}
- if (libxl_domain_core_dump(&priv->ctx, dom->id, to) != 0) {
+ if (libxl_domain_core_dump(priv->ctx, dom->id, to, NULL) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to dump core of domain '%d' with libxenlight"),
dom->id);
@@ -2048,7 +2149,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
libxlDriverLock(driver);
if (flags & VIR_DUMP_CRASH) {
- if (libxlVmReap(driver, vm, 1, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
+ if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), dom->id);
goto cleanup_unlock;
@@ -2069,7 +2170,7 @@ cleanup_unlock:
libxlDriverUnlock(driver);
cleanup_unpause:
if (virDomainObjIsActive(vm) && paused) {
- if (libxl_domain_unpause(&priv->ctx, dom->id) != 0) {
+ if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("After dumping core, failed to resume domain '%d' with"
" libxenlight"), dom->id);
@@ -2227,7 +2328,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
libxlDomainObjPrivatePtr priv;
virDomainDefPtr def;
virDomainObjPtr vm;
- libxl_cpumap map;
+ libxl_bitmap map;
uint8_t *bitmask = NULL;
unsigned int maplen;
unsigned int i, pos;
@@ -2322,7 +2423,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
break;
case VIR_DOMAIN_VCPU_LIVE:
- if (libxl_set_vcpuonline(&priv->ctx, dom->id, &map) != 0) {
+ if (libxl_set_vcpuonline(priv->ctx, dom->id, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
" with libxenlight"), dom->id);
@@ -2331,7 +2432,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
break;
case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
- if (libxl_set_vcpuonline(&priv->ctx, dom->id, &map) != 0) {
+ if (libxl_set_vcpuonline(priv->ctx, dom->id, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
" with libxenlight"), dom->id);
@@ -2427,7 +2528,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
int ret = -1;
- libxl_cpumap map;
+ libxl_bitmap map;
libxlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -2448,7 +2549,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
map.size = maplen;
map.map = cpumap;
- if (libxl_set_vcpuaffinity(&priv->ctx, dom->id, vcpu, &map) != 0) {
+ if (libxl_set_vcpuaffinity(priv->ctx, dom->id, vcpu, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
@@ -2511,7 +2612,7 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
}
priv = vm->privateData;
- if ((vcpuinfo = libxl_list_vcpu(&priv->ctx, dom->id, &maxcpu,
+ if ((vcpuinfo = libxl_list_vcpu(priv->ctx, dom->id, &maxcpu,
&hostcpus)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to list vcpus for domain '%d' with libxenlight"),
@@ -2538,7 +2639,7 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
MIN(maplen, vcpuinfo[i].cpumap.size));
}
- libxl_vcpuinfo_destroy(&vcpuinfo[i]);
+ libxl_vcpuinfo_dispose(&vcpuinfo[i]);
}
VIR_FREE(vcpuinfo);
@@ -2596,7 +2697,7 @@ libxlDomainXMLFromNative(virConnectPtr conn, const char * nativeFormat,
goto cleanup;
}
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ if ((ver_info = libxl_get_version_info(driver->ctx)) == NULL) {
VIR_ERROR(_("cannot get version information from libxenlight"));
goto cleanup;
}
@@ -2639,7 +2740,7 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
goto cleanup;
}
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ if ((ver_info = libxl_get_version_info(driver->ctx)) == NULL) {
VIR_ERROR(_("cannot get version information from libxenlight"));
goto cleanup;
}
@@ -2899,10 +3000,10 @@ libxlDomainChangeEjectableMedia(libxlDomainObjPrivatePtr priv,
return -1;
}
- if (libxlMakeDisk(vm->def, disk, &x_disk) < 0)
+ if (libxlMakeDisk(disk, &x_disk) < 0)
goto cleanup;
- if ((ret = libxl_cdrom_insert(&priv->ctx, vm->def->id, &x_disk)) < 0) {
+ if ((ret = libxl_cdrom_insert(priv->ctx, vm->def->id, &x_disk, NULL)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to change media for disk '%s'"),
disk->dst);
@@ -2954,11 +3055,11 @@ libxlDomainAttachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
goto cleanup;
}
- if (libxlMakeDisk(vm->def, l_disk, &x_disk) < 0)
+ if (libxlMakeDisk(l_disk, &x_disk) < 0)
goto cleanup;
- if ((ret = libxl_device_disk_add(&priv->ctx, vm->def->id,
- &x_disk)) < 0) {
+ if ((ret = libxl_device_disk_add(priv->ctx, vm->def->id,
+ &x_disk, NULL)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to attach disk '%s'"),
l_disk->dst);
@@ -2991,7 +3092,6 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
virDomainDiskDefPtr l_disk = NULL;
libxl_device_disk x_disk;
int i;
- int wait_secs = 2;
int ret = -1;
switch (dev->data.disk->device) {
@@ -3008,11 +3108,11 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
l_disk = vm->def->disks[i];
- if (libxlMakeDisk(vm->def, l_disk, &x_disk) < 0)
+ if (libxlMakeDisk(l_disk, &x_disk) < 0)
goto cleanup;
- if ((ret = libxl_device_disk_del(&priv->ctx, &x_disk,
- wait_secs)) < 0) {
+ if ((ret = libxl_device_disk_remove(priv->ctx, vm->def->id,
+ &x_disk, NULL)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to detach disk '%s'"),
l_disk->dst);
@@ -3383,13 +3483,13 @@ libxlNodeGetFreeMemory(virConnectPtr conn)
const libxl_version_info* ver_info;
libxlDriverPrivatePtr driver = conn->privateData;
- if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
+ if (libxl_get_physinfo(driver->ctx, &phy_info)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_physinfo_info failed"));
return 0;
}
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ if ((ver_info = libxl_get_version_info(driver->ctx)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_version_info failed"));
return 0;
@@ -3536,7 +3636,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
char * ret = NULL;
- int sched_id;
+ libxl_scheduler sched_id;
libxlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -3553,31 +3653,29 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
}
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to get scheduler id for domain '%d'"
- " with libxenlight"), dom->id);
- goto cleanup;
- }
+ sched_id = libxl_get_scheduler(priv->ctx);
if (nparams)
*nparams = 0;
switch (sched_id) {
- case XEN_SCHEDULER_SEDF:
+ case LIBXL_SCHEDULER_SEDF:
ret = strdup("sedf");
break;
- case XEN_SCHEDULER_CREDIT:
+ case LIBXL_SCHEDULER_CREDIT:
ret = strdup("credit");
if (nparams)
*nparams = XEN_SCHED_CREDIT_NPARAM;
break;
- case XEN_SCHEDULER_CREDIT2:
+ case LIBXL_SCHEDULER_CREDIT2:
ret = strdup("credit2");
break;
- case XEN_SCHEDULER_ARINC653:
+ case LIBXL_SCHEDULER_ARINC653:
ret = strdup("arinc653");
break;
default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to get scheduler id for domain '%d'"
+ " with libxenlight"), dom->id);
goto cleanup;
}
@@ -3599,8 +3697,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
- libxl_sched_credit sc_info;
- int sched_id;
+ libxl_domain_sched_params sc_info;
+ libxl_scheduler sched_id;
int ret = -1;
virCheckFlags(0, -1);
@@ -3610,31 +3708,28 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
libxlDriverUnlock(driver);
if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
+ virReportError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
goto cleanup;
}
if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Domain is not running"));
goto cleanup;
}
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to get scheduler id for domain '%d'"
- " with libxenlight"), dom->id);
- goto cleanup;
- }
+ sched_id = libxl_get_scheduler(priv->ctx);
- if (sched_id != XEN_SCHEDULER_CREDIT) {
+ if (sched_id != LIBXL_SCHEDULER_CREDIT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
- if (libxl_sched_credit_domain_get(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_get(priv->ctx, dom->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
@@ -3677,7 +3772,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
- libxl_sched_credit sc_info;
+ libxl_domain_sched_params sc_info;
int sched_id;
int i;
int ret = -1;
@@ -3707,20 +3802,15 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to get scheduler id for domain '%d'"
- " with libxenlight"), dom->id);
- goto cleanup;
- }
+ sched_id = libxl_get_scheduler(priv->ctx);
- if (sched_id != XEN_SCHEDULER_CREDIT) {
+ if (sched_id != LIBXL_SCHEDULER_CREDIT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
- if (libxl_sched_credit_domain_get(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_get(priv->ctx, dom->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
@@ -3737,7 +3827,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
}
}
- if (libxl_sched_credit_domain_set(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_set(priv->ctx, dom->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
--
1.7.10.4
11 years, 11 months
[libvirt] [PATCH 0/3] add pci-bridge device and address type
by liguang
Now, it's unnecessary to arrange devices into multi-pci-bus,
for example:
<sound model='ac97'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x1' slot='0x02' function='0x0'/>
</video>
libvirt will complain about "bus != 0",
fortunately, qemu supports pci-to-pci bridge,
if we want to use multi-pci-bus, we can define
2 pci bridge devices then attach 1 to the other
as a subordinate pci-bus, so, 2 pci-buses appear.
for example:
<pci-bridge type='root'/>
<pci-bridge type='subordinate'>
<address type='pci-bridge' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</pci-bridge>
<sound model='ac97'>
<address type='pci-bridge' domain='0x0000' bus='0x01' slot='0x02' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci-bridge' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
src/conf/domain_conf.c | 88 +++++++++++++++++++++++++++++++++++++++++++++---
src/conf/domain_conf.h | 22 ++++++++++++
src/qemu/qemu_command.c | 52 +++++++++++++++++++++++++++++++++++++++++++---
docs/formatdomain.html.in | 23 +++++++++++++++++++++++
4 files changed, 176 insertions(+), 9 deletions(-)
11 years, 11 months
[libvirt] [PATCH 0/2] Add virsh commands to modify cpu node and model node of a domain XML
by Ken ICHIKAWA
From: Ken ICHIKAWA <ichikawa.ken(a)jp.fujitsu.com>
This patchset adds two virsh commands, "confcpu" and "confcpu-model".
"confcpu" allows to modify 'mode' attirbute and 'match' attribute of
a cpu node of a domain XML.
"confcpu-model" allows to modify cpu model, 'fallback' attribute and
'vendor_id' attribute of a model node of a domain XML.
By using these commands, we can easily change cpu mode, model and etc. by
hand or shellscript without editing XML.
Ken ICHIKAWA (2):
virsh: Add a new command "confcpu"
virsh: Add a new command "confcpu-model"
tools/virsh-domain.c | 411 +++++++++++++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 51 +++++++
2 files changed, 462 insertions(+)
--
1.7.11.7
11 years, 11 months
[libvirt] [PATCH 0/4 v2] ivshmem support
by Osier Yang
v1 - v2:
* Change attribute "model" to be a sub-element instead.
NOTE:
Since the invshmem server socket path is not created by
QEMU, but by an external app called "ivshmem_server", It's
not good to construct the socket path in libvirt with a solid
rule, and force the user to figure out what the path is
libvirt uses first and use that for "ivshmem_server". Thus it's
the user's business to set the selinux context on the socket
path so that the qemu process could be started successfully
when selinux is enabled.
Shawn Furrow proposed a patch more than a month ago:
https://www.redhat.com/archives/libvir-list/2012-September/msg01612.html
But this is a complete different implementation. Considering
there could be other memory related devices in futuer, this
introduces a new device model, called "memory device", instead
of a specific device like "ivshmem", though only "ivshmem"
is supported currently. Please refer to PATCH 1/4 for more
details.
CC'ed to Cam and Shawn, to see if there is advise on the documents.
Osier Yang (4):
docs: Add documents for memory device
conf: Parse and format memory device XML
qemu: Add cap flag QEMU_CAPS_IVSHMEM
qemu: Build command line for ivshmem device
docs/formatdomain.html.in | 40 +++++
docs/schemas/domaincommon.rng | 40 +++++
src/conf/domain_conf.c | 195 +++++++++++++++++++++-
src/conf/domain_conf.h | 27 +++
src/libvirt_private.syms | 3 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 85 ++++++++++
src/util/util.c | 5 +
src/util/util.h | 2 +
tests/qemuhelptest.c | 12 +-
tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args | 7 +
tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml | 34 ++++
tests/qemuxml2argvtest.c | 2 +
14 files changed, 450 insertions(+), 5 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
--
1.7.7.6
11 years, 11 months
[libvirt] [PATCH 0/5] Add API to tunnel channels
by John Eckersberg
This series enables the qemu driver to tunnel a virtio channel. This
is useful for a remote session to communicate with a guest channel via
the streaming API.
This was originally fleshed out a while back in this thread:
https://www.redhat.com/archives/libvir-list/2011-September/msg01049.html
This implements only item (3) in that list.
The new API is nearly identical to the existing virDomainOpenConsole
API, except it works on channels, and supports UNIX sockets in
addition to PTYs for channel source type.
This is my first libvirt patch, please be gentle :)
John Eckersberg (5):
api: Add API to tunnel a guest channel via stream
conf: Rename virconsole.* to virchrdev.*
conf: Rename console-specific identifiers to be more generic
conf: Add unix socket support to virChrdevOpen
qemu: Implement virDomainOpenChannel API
configure.ac | 48 ++---
include/libvirt/libvirt.h.in | 16 ++
po/POTFILES.in | 2 +-
src/Makefile.am | 8 +-
src/conf/virchrdev.c | 442 +++++++++++++++++++++++++++++++++++++++++++
src/conf/virchrdev.h | 37 ++++
src/conf/virconsole.c | 414 ----------------------------------------
src/conf/virconsole.h | 36 ----
src/driver.h | 7 +
src/libvirt.c | 61 ++++++
src/libvirt_private.syms | 8 +-
src/libvirt_public.syms | 5 +
src/qemu/qemu_domain.c | 4 +-
src/qemu/qemu_domain.h | 4 +-
src/qemu/qemu_driver.c | 81 +++++++-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 9 +-
src/remote_protocol-structs | 6 +
18 files changed, 697 insertions(+), 492 deletions(-)
create mode 100644 src/conf/virchrdev.c
create mode 100644 src/conf/virchrdev.h
delete mode 100644 src/conf/virconsole.c
delete mode 100644 src/conf/virconsole.h
--
1.7.11.7
11 years, 11 months
[libvirt] [ESX:Error] HTTP 403 error for CURL upload operation
by Ata Bohra
Hi Everyone, Merry Christmas and Happy New Year! I'm trying to upload disk to ESX 5.0 server using the URL obtained by the server (during VM installation process); I'm using libcurl support in libvirt to upload the disk, but I get this error on file upload:----------------------* About to connect() to <ip> port 443 (#1)
* Trying <ip>... * connected
* found 153 certificates in /etc/ssl/certs/ca-certificates.crt
* server certificate verification SKIPPED
* compression: NULL
* cipher: AES-128-CBC
* MAC: SHA1
> PUT /ha-nfc/52c6d592-7636-67c5-29f3-d5b373be4f42/disk-0.vmdk HTTP/1.1
User-Agent: libvirt-esx
Host: <ip>
Accept: */*
Cookie: vmware_soap_session="521af33d-2bbe-38aa-21e8-13d474ccb023"
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:vim25"
Content-Length: 7021568< HTTP/1.1 403 Forbidden
< Date: Sun, 30 Dec 2012 01:28:19 GMT
< Connection: close
< Content-Type: text; charset=plain
< Content-Length: 44
----------------------To achieve this operation I've added a routine to support file Upload (for ESX driver as currently it only support buffer upload), I verified its functioning my uploading a file using datastore based URL:(http(s)//<ip>/file??dcPath=ha-datacenter?dsName=xxx). CURL options provided by me are; ----------- curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl->handle, CURLOPT_URL, url);
curl_easy_setopt(curl->handle, CURLOPT_READDATA, <data pointer>);
curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE_LARGE,
(curl_off_t) fileData->size);
curl_easy_setopt(curl->handle, CURLOPT_READFUNCTION,
<read function>);
curl_easy_setopt(curl->handle, CURLOPT_VERBOSE, 1);------------------------ My understanding is there needs to be some tuning done to ESX server to accept this upload operation, please suggest if anyone has faced this issue before. Thanks!Ata
11 years, 11 months
[libvirt] libvirtd segfault
by Scott Sullivan
### Libvirt version: ###
libvirt tagged v1.0.0 from git , with
f0e72b2f5c675f927d04545dc5095f9e5998f171 applied
### Problem: ###
Libvirtd segfaults
### Steps to reproduce: ###
This is difficult to reproduce; but appears to happen only when doing
'virsh destroys', and when they are ran in concurrent intervals, over
extended periods of time.
Here are the steps I have taken to reproduce this problem
(debian_6.0_amd64_kvm.img.gz is just a zipped up squeeze stock ISO install):
First, copy this script to ease the steps (assumed to be at
/root/libvirt_crash.pl later):
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use String::Random;
use UUID::Random;
my ($lvms,$sleep,$restarts_per_lvm);
GetOptions(
'lvms=i' => \$lvms,
'restarts_per_lvm=i' => \$restarts_per_lvm,
'sleep=i' => \$sleep,
);
die "USAGE:\n$0 [--lvms int | --restarts_per_lvm int | --sleep int
(optional) ]\n" unless ( $lvms && $restarts_per_lvm );
sub _create_lvm {
my $opts = shift;
print "\tlvcreate -n $opts->{lvm} -L 5G /dev/LVM\n";
system("lvcreate -n $opts->{lvm} -L 5G /dev/LVM");
}
sub _kpartx_lvm {
my $opts = shift;
die "_kpartx_lvm needs modifier!\n" unless ( $opts->{modifier} );
print "\tkpartx -p p -$opts->{modifier} -v
/dev/LVM/$opts->{lvm}\n";
system("kpartx -p p -$opts->{modifier} -v /dev/LVM/$opts->{lvm}");
}
sub _remove_lvm {
my $opts = shift;
print "\tlvremove -f /dev/LVM/$opts->{lvm}\n";
system("lvremove -f /dev/LVM/$opts->{lvm}");
unlink("/xen/configs/$opts->{lvm}.cfg");
}
sub _display_lvm {
my $opts = shift;
print "\tparted -s /dev/LVM/$opts->{lvm} unit gb p\n";
system("parted -s /dev/LVM/$opts->{lvm} unit gb p");
}
sub _dd_template {
my $opts = shift;
print "\tdd if=/root/ssullivan/debian_6.0_amd64_kvm.img.gz
bs=1M | gunzip -c | dd of=/dev/LVM/$opts->{lvm} bs=1M\n";
system("dd if=/root/ssullivan/debian_6.0_amd64_kvm.img.gz bs=1M
| gunzip -c | dd of=/dev/LVM/$opts->{lvm} bs=1M");
}
sub _e2fsck_lvm {
my $opts = shift;
print "\te2fsck -y -f /dev/mapper/LVM-$opts->{lvm}p1\n";
system("e2fsck -y -f /dev/mapper/LVM-$opts->{lvm}p1");
print "\te2fsck -y -f /dev/mapper/LVM-$opts->{lvm}p3\n";
system("e2fsck -y -f /dev/mapper/LVM-$opts->{lvm}p3")
}
sub _place_virtconf {
my $opts = shift;
my $uuid = UUID::Random::generate;
my $virt_conf = <<END;
<domain type="kvm">
<name>$opts->{lvm}</name>
<uuid>$uuid</uuid>
<memory>450560</memory>
<currentMemory>450560</currentMemory>
<vcpu>2</vcpu>
<cpu>
<topology sockets="2" cores="4" threads="1"/>
</cpu>
<os>
<type arch="x86_64" machine="pc-1.1">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="localtime"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/opt/libexec/qemu-kvm-wrapper</emulator>
<disk type="block" device="disk">
<driver name="qemu" cache="none"/>
<source dev="/dev/LVM/$opts->{lvm}"/>
<target dev="vda" bus="virtio"/>
</disk>
<serial type="pty">
<target port="1"/>
</serial>
<console type="pty">
<target port="1"/>
</console>
<input type="tablet" bus="usb"/>
<input type="mouse" bus="ps2"/>
<graphics type="vnc" port="-1" autoport="yes" keymap="en-us"/>
</devices>
</domain>
END
open(my $fh, '>', "/xen/configs/$opts->{lvm}.cfg") || die
"Error opening [/xen/configs/$opts->{lvm}.cfg] [$!]";
print $fh "$virt_conf\n";
close($fh) || die "Error closing
[/xen/configs/$opts->{lvm}.cfg] [$!]";
}
sub _shutdown_lvm {
my $opts = shift;
print "\tvirsh destroy $opts->{lvm}\n";
system("virsh destroy $opts->{lvm}");
_virsh_list();
}
sub _virsh_list {
print "\tvirsh list\n";
system('virsh list');
}
sub _start_lvm {
my $opts = shift;
print "\tvirsh create /xen/configs/$opts->{lvm}.cfg\n";
system("virsh create /xen/configs/$opts->{lvm}.cfg");
_virsh_list();
}
my $rnd = new String::Random;
my $count = 0;
while ( $count < $lvms ) {
my $id = $rnd->randpattern("cccccccc");
print "####\nLVM PASS: $count\nLVM: $id\n####\n";
print "Creating LVM...\n";
_create_lvm({ lvm => $id });
print "DD'ing template...\n";
_dd_template({ lvm => $id });
print "kpartxA LVM...\n";
_kpartx_lvm({ lvm => $id, modifier => 'a' });
print "e2fsck LVM..\n";
_e2fsck_lvm({ lvm => $id });
print "kpartxD LVM...\n";
_kpartx_lvm({ lvm => $id, modifier => 'd' });
print "Placing libvirt conf...\n";
_place_virtconf({ lvm => $id });
print "Partition setup:\n";
_display_lvm({ lvm => $id });
print "Performing $restarts_per_lvm restarts on $id...\n";
my $restart_cnt = 0;
while ( $restart_cnt < $restarts_per_lvm ) {
print "####\nRESTART PASS: $restart_cnt\nLVM: $id\n####\n";
print "Shutting down LVM...\n";
_shutdown_lvm({ lvm => $id });
sleep $sleep if ( $sleep );
print "Starting LVM...\n";
_start_lvm({ lvm => $id });
$restart_cnt++;
}
print "Removing LVM...\n";
_shutdown_lvm({ lvm => $id });
_remove_lvm({ lvm => $id });
$count++;
}
I then started 21 of these scripts, with the below commands (preferably
in a screen to reduce spamming):
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 --sleep 10 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 --sleep 10 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 1000 --restarts_per_lvm 2000 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
perl /root/libvirt_crash.pl --lvms 6000 --restarts_per_lvm 30 &
I already had libvirtd started under GDB at this point. I waited about
3-6 hours, and I found this in my GDB session:
2012-12-27 17:23:35.922+0000: 7445: error : qemuMonitorIO:614 : internal
error End of file from monitor
2012-12-27 17:23:36.558+0000: 7445: error : qemuMonitorIO:614 : internal
error End of file from monitor
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff8e1fc700 (LWP 31142)]
qemuDomainObjBeginJobInternal (driver=0x7fffe401d740,
driver_locked=true, obj=0x7fff80001b00, job=QEMU_JOB_DESTROY,
asyncJob=QEMU_ASYNC_JOB_NONE) at qemu/qemu_domain.c:768
768 priv->jobs_queued++;
Missing separate debuginfos, use: debuginfo-install
audit-libs-2.1.3-3.el6.x86_64 augeas-libs-0.9.0-1.el6.x86_64
avahi-libs-0.6.25-11.el6.x86_64 cyrus-sasl-gssapi-2.1.23-13.el6.x86_64
cyrus-sasl-lib-2.1.23-13.el6.x86_64 cyrus-sasl-md5-2.1.23-13.el6.x86_64
cyrus-sasl-plain-2.1.23-13.el6.x86_64 db4-4.7.25-16.el6.x86_64
dbus-libs-1.2.24-5.el6_1.x86_64 device-mapper-libs-1.02.66-6.el6.x86_64
glibc-2.12-1.47.el6.x86_64 gnutls-2.8.5-4.el6.x86_64
keyutils-libs-1.4-3.el6.x86_64 krb5-libs-1.9-22.el6_2.1.x86_64
libblkid-2.17.2-12.4.el6.x86_64 libcap-ng-0.6.4-3.el6_0.1.x86_64
libcom_err-1.41.12-11.el6.x86_64 libcurl-7.19.7-26.el6_1.2.x86_64
libgcrypt-1.4.5-9.el6.x86_64 libgpg-error-1.7-4.el6.x86_64
libidn-1.18-2.el6.x86_64 libnl-1.1-14.el6.x86_64
libpcap-1.0.0-6.20091201git117cb5.el6.x86_64
libpciaccess-0.12.1-1.el6.x86_64 libselinux-2.0.94-5.2.el6.x86_64
libsepol-2.0.41-4.el6.x86_64 libtasn1-2.3-3.el6.x86_64
libudev-147-2.40.el6.x86_64 libuuid-2.17.2-12.4.el6.x86_64
libxml2-2.7.6-4.el6.x86_64 libxslt-1.1.26-2.el6.x86_64
netcf-libs-0.1.9-2.el6.x86_64 nspr-4.8.8-3.el6.x86_64
nss-3.12.10-17.el6_2.x86_64 nss-softokn-freebl-3.12.9-11.el6.x86_64
nss-util-3.12.10-2.el6.x86_64 numactl-2.0.3-9.el6.x86_64
openldap-2.4.23-20.el6.x86_64 openssl-1.0.0-20.el6.x86_64
yajl-1.0.7-3.el6.x86_64 zlib-1.2.3-27.el6.x86_64
(gdb)
Here is the output of 'thread apply all bt' from this session:
Thread 30 (Thread 0x7fff8e1fc700 (LWP 31142)):
#0 qemuDomainObjBeginJobInternal (driver=0x7fffe401d740,
driver_locked=true, obj=0x7fff80001b00, job=QEMU_JOB_DESTROY,
asyncJob=QEMU_ASYNC_JOB_NONE) at qemu/qemu_domain.c:768
#1 0x00007fffeac2b223 in qemuDomainDestroyFlags (dom=<value optimized
out>, flags=<value optimized out>) at qemu/qemu_driver.c:2052
#2 0x00000039f10f97df in virDomainDestroy (domain=0x7fff741b8540) at
libvirt.c:2201
#3 0x0000000000428e22 in remoteDispatchDomainDestroy (server=<value
optimized out>, client=<value optimized out>, msg=<value optimized out>,
rerr=0x7fff8e1fbbe0, args=<value optimized out>, ret=<value optimized
out>) at remote_dispatch.h:1277
#4 remoteDispatchDomainDestroyHelper (server=<value optimized out>,
client=<value optimized out>, msg=<value optimized out>,
rerr=0x7fff8e1fbbe0, args=<value optimized out>, ret=<value optimized
out>) at remote_dispatch.h:1255
#5 0x00000039f1146152 in virNetServerProgramDispatchCall
(prog=0x6884a0, server=0x67fe60, client=0x68eb50, msg=0x6930b0) at
rpc/virnetserverprogram.c:431
#6 virNetServerProgramDispatch (prog=0x6884a0, server=0x67fe60,
client=0x68eb50, msg=0x6930b0) at rpc/virnetserverprogram.c:304
#7 0x00000039f1143fee in virNetServerProcessMsg (srv=<value optimized
out>, client=0x68eb50, prog=<value optimized out>, msg=0x6930b0) at
rpc/virnetserver.c:171
#8 0x00000039f1144a8b in virNetServerHandleJob (jobOpaque=<value
optimized out>, opaque=<value optimized out>) at rpc/virnetserver.c:192
#9 0x00000039f10643ec in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:144
#10 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#11 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#12 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 29 (Thread 0x7fff8ebfd700 (LWP 20241)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 28 (Thread 0x7fff8f5fe700 (LWP 20235)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 27 (Thread 0x7fff8ffff700 (LWP 29349)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 26 (Thread 0x7fffb8dfa700 (LWP 29348)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 25 (Thread 0x7fffb97fb700 (LWP 28577)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 24 (Thread 0x7fffba1fc700 (LWP 28576)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 23 (Thread 0x7fffbabfd700 (LWP 28180)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 22 (Thread 0x7fffbb5fe700 (LWP 28178)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 21 (Thread 0x7fffe0dfa700 (LWP 12076)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 20 (Thread 0x7fffe17fb700 (LWP 5934)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 19 (Thread 0x7fffe21fc700 (LWP 5904)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 18 (Thread 0x7fffe2bfd700 (LWP 5860)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 17 (Thread 0x7fffbbfff700 (LWP 855)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 16 (Thread 0x7fffe97c4700 (LWP 835)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 11 (Thread 0x7fffec73f700 (LWP 7457)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 10 (Thread 0x7fffed140700 (LWP 7456)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 9 (Thread 0x7fffedb41700 (LWP 7455)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 8 (Thread 0x7fffee542700 (LWP 7454)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 7 (Thread 0x7fffeef43700 (LWP 7453)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 6 (Thread 0x7fffef944700 (LWP 7452)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 5 (Thread 0x7ffff0345700 (LWP 7451)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 4 (Thread 0x7ffff0d46700 (LWP 7450)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 3 (Thread 0x7ffff1747700 (LWP 7449)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7ffff2148700 (LWP 7448)):
#0 0x000000300a20b3dc in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00000039f1063eb6 in virCondWait (c=<value optimized out>, m=<value
optimized out>) at util/threads-pthread.c:117
#2 0x00000039f1064483 in virThreadPoolWorker (opaque=<value optimized
out>) at util/threadpool.c:103
#3 0x00000039f1063cd9 in virThreadHelper (data=<value optimized out>)
at util/threads-pthread.c:161
#4 0x000000300a2077f1 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003009ae570d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7ffff7fda800 (LWP 7445)):
#0 0x0000003009a46f60 in vfprintf () from /lib64/libc.so.6
#1 0x0000003009afc970 in __vsnprintf_chk () from /lib64/libc.so.6
#2 0x0000003009afc8aa in __snprintf_chk () from /lib64/libc.so.6
#3 0x00000039f108144a in snprintf (when=<value optimized out>,
buf=0x7fffffffd470 "2012-12-27 17:23:36.561+0000") at
/usr/include/bits/stdio2.h:65
#4 virTimeStringThenRaw (when=<value optimized out>, buf=0x7fffffffd470
"2012-12-27 17:23:36.561+0000") at util/virtime.c:219
#5 0x00000039f108167a in virTimeStringNowRaw (buf=0x7fffffffd470
"2012-12-27 17:23:36.561+0000") at util/virtime.c:195
#6 0x00000039f105834b in virLogVMessage (source=VIR_LOG_FROM_FILE,
priority=<value optimized out>, filename=0x39f11ad70b
"util/event_poll.c", linenr=378, funcname=0x39f11adcc0
"virEventPollMakePollFDs", fmt=<value optimized out>,
vargs=0x7fffffffd4f0) at util/logging.c:822
#7 0x00000039f10586ec in virLogMessage (source=<value optimized out>,
priority=<value optimized out>, filename=<value optimized out>,
linenr=<value optimized out>, funcname=<value optimized out>, fmt=<value
optimized out>) at util/logging.c:753
#8 0x00000039f1052241 in virEventPollMakePollFDs () at
util/event_poll.c:374
#9 virEventPollRunOnce () at util/event_poll.c:605
#10 0x00000039f1051666 in virEventRunDefaultImpl () at util/event.c:247
#11 0x00000039f11437dd in virNetServerRun (srv=0x67fe60) at
rpc/virnetserver.c:1004
#12 0x000000000040c5a3 in main (argc=<value optimized out>, argv=<value
optimized out>) at libvirtd.c:1354
(gdb)
Does anyone have any insights as to the cause of this, or any potential
solutions? If there's anything I can add that would help let me know.
11 years, 11 months
[libvirt] Coverity scan
by John Ferlan
First allow me to introduce myself - I'm John Ferlan a new Red Hat employee (3 weeks). I came from the closed world at HP where for the last 7 years I worked in a group developing/supporting HP's Integrity Virtual Machine software prior to it being outsourced to India this past May. I primarily worked in the CLI/API and daemon space, although I also spent quite a bit of time in the lower virtualization layers which mimicked the Integrity instructions. I am very happy to be in the open world and look forward to contributing. Everyone has to start some where.
My first task here at Red Hat was to triage a Coverity scan executed against libvirt-1.0.0-1.fc19.src.rpm done in late November. There were 285 issues documented. I quickly found that some of the defects found there were already fixed in later submits upstream, so I ran a new Coverity scan last Friday and it came back with 297 issues broken down as follows:
1 ARRAY_VS_SINGLETON
33 BAD_SIZEOF
17 CHECKED_RETURN
1 CONSTANT_EXPRESSION_RESULT
5 COPY_PASTE_ERROR
13 DEADCODE
46 FORWARD_NULL
2 MISSING_RETURN
2 NEGATIVE_RETURNS
7 NULL_RETURNS
1 OVERRUN
137 RESOURCE_LEAK
18 REVERSE_INULL
1 SIGN_EXTENSION
3 UNINIT
8 UNUSED_VALUE
2 USE_AFTER_FREE
Of the defects found there are quite a few which can be considered as "false positives", some are trivial issues, a few complex issues, and the rest while resulting in a core usually occur in some error path. The bulk of the BAD_SIZEOF errors are the result of using a %p in the PROBE macro on structure pointers - it's a false positive, yet annoying. The bulk of FORWARD_NULL defects are from a false positive in vbox_templ.c. The bulk of RESOURCE_LEAK defects are from the use of macros to build code in esx_vi_types - which is where I'm triaging now. Of all the errors listed, "only" 62 files are affected.
Over the next few weeks, I'll start sending patch requests starting with some of the trivial problems just so I can get my feet wet with the process as it's certainly different than my closed world experiences. Since part of that process is to communicate early so people know what you're doing and what's coming - that's what I'm doing!
Also, now that I have a bit of experience with Coverity - I can run it again (more frequently) against the latest upstream bits.
John Ferlan
11 years, 11 months
[libvirt] [RFC] Refactoring bridge driver for portability
by Roman Bogorodskiy
Hi,
Few weeks ago when I have submitted my all-in-one huge FreeBSD,
Eric made some comments on the networking part:
http://www.redhat.com/archives/libvir-list/2012-December/msg00432.html
Now when we're done with most of the other things, I'd like
to discuss networking in more detail.
Basically, the main question that bothers me is what would be the
best way to refactor network/bridge_driver.c?
Currently it contains a number of things:
- dnsmasq routines, static, but cross-platform, doesn't need
any changes (at least major ones)
- the same for radvd
- minor firewalld bits, that are linux specifc
- iptables routines. There are quite a lot of that code
and it's also gets called from many places in the file
I'm thinking about an approach that Eric mentioned for virthread.c:
- keep dnsmasq and radvd in bridge_driver.c
- move out all linux specific code to bridge_driver_linux.c and
#include it in a way similar to virthread.c
- in a similar way create bridge_driver_freebsd.c
Does it sound reasonable?
Roman Bogorodskiy
11 years, 11 months