[libvirt] Fwd: Supporting native USB in oVirt
by Oved Ourfalli
Hey,
We are now working on adding the support for native USB devices on oVirt, and we have some difficulties.
Please see the details/discussion below.
Thank you for your help,
Oved
----- Forwarded Message -----
From: "Itamar Heim" <iheim(a)redhat.com>
To: "Michal Privoznik" <mprivozn(a)redhat.com>
Cc: "Oved Ourfalli" <ovedo(a)redhat.com>, "Dave Allan" <dallan(a)redhat.com>, "Jiri Denemark" <jdenemar(a)redhat.com>, "Igor Lvovsky" <ilvovsky(a)redhat.com>, "Eli Mesika" <emesika(a)redhat.com>, "Hans de Goede" <hdegoede(a)redhat.com>, "Dan Kenigsberg" <danken(a)redhat.com>, "Andrew Cathrow" <acathrow(a)redhat.com>
Sent: Wednesday, May 9, 2012 1:18:40 PM
Subject: Re: Supporting native USB in oVirt
On 05/09/2012 01:12 PM, Michal Privoznik wrote:
> On 08.05.2012 09:19, Oved Ourfalli wrote:
>> Hi,
>>
>> We are now working on adding the support for native USB devices on oVirt.
>> As far as we understand, in order to use it we need to pass the following devices with the following restrictions (according to the EHCI spec):
>> 1. EHCI USB controller - with the highest function number, #7.
>>
>> devices='{type:controller,device:usb,model:ich9-ehci1,address:{type:pci,domain:0x0000,bus:0x00,slot:0x04,function:0x7}}'
>>
>> 2. 3 UHCI USB controllers, on the same bus and PCI slot as the EHCI controller. Set the multifunction bit to on, on the controller with function #0.
>>
>> devices='{type:controller,device:usb,model:ich9-uhci1,master:{startport:0},address:{type:pci,domain:0x0000,bus:0x00,slot:0x04,function:0x0,multifunction:on}}'
>> devices='{type:controller,device:usb,model:ich9-uhci2,master:{startport:2},address:{type:pci,domain:0x0000,bus:0x00,slot:0x04,function:0x1}}'
>> devices='{type:controller,device:usb,model:ich9-uhci3,master:{startport:4},address:{type:pci,domain:0x0000,bus:0x00,slot:0x04,function:0x2}}'
>>
>> 3. USB redirect devices (according to the needed number of USB slots, maximum 6) on the same bus, each one having a different port.
>>
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:1}}'
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:2}}'
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:3}}'
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:4}}'
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:5}}'
>> devices='{type:redir,device:spicevmc,bus:usb,address:{type:usb,bus:0,port:6}}'
>>
>> 4. If we want more than 6 USB slots, we need to have 2 EHCI controllers, and 6 UHCI controllers, that are consistent with the restrictions above, on different bus.
>> (we need them to be on different bus, since the connection between the redirect devices and the controllers is the bus).
>>
>> According to Hans (cc-ed), if we let libvirt pick its own addresses, it will put each controller of the composite USB controller device on its own pci slot, which is a violation of the EHCI spec.
>
>>
>> The problem is that the oVirt engine is not aware of addresses. They aren't managed by it.
>> They are chosen automatically by libvirt, returned to the engine, and they saved in the engine database in order to provide the ability to retain the same PCI addresses after VM restart.
>>
>> So, in order to support the EHCI spec, oVirt will have to be aware of addresses, manage them (allocate them, check for collisions, update on every libvirt change regarding that, etc...). Obviously, it doesn't feel right, and in fact it is also not feasible, to manage these addresses in the oVirt domain.
>>
>> Is all the above correct, or are we missing something?
>> If so, can you address the issues above, and provide the ability to manage these devices in libvirt?
>
> Let's have this conversation upstream (libvirt-list(a)redhat.com). Many
> developers are there so if there's anything libvirt can do, we should
> agree on concept there.
12 years, 8 months
[libvirt] [PATCH] usb: fix crash when failing to attach a second usb device
by Guannan Ren
when failing to attach another usb device to a domain for some reason
which has one use device attached before, the libvirtd crashed.
The crash is caused by null-pointer dereference error in invoking
usbDeviceListSteal passed in NULL value usb variable.
commit 05abd1507d66aabb6cad12eeafeb4c4d1911c585 introduces the bug.
---
src/qemu/qemu_hotplug.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ad31eba..9b60816 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1213,7 +1213,8 @@ error:
cleanup:
usbDeviceListFree(list);
- usbDeviceListSteal(driver->activeUsbHostdevs, usb);
+ if (usb)
+ usbDeviceListSteal(driver->activeUsbHostdevs, usb);
return -1;
}
--
1.7.7.5
12 years, 8 months
[libvirt] [Patch] Libvirt - Fix locking for readonly devices
by David Weber
Hi,
I'm currently working on getting sanlock into Debian/Ubuntu.
While testing, I noticed that I wasn't able to add a readonly
or shared device: "internal error unsupported
configuration: Readonly leases are not supported".
After looking into the source, it seems to be the following
situation:
- Libvirt passes every device to the sanlock plugin, even if
it is readonly
- The sanlock plugin rejects to add a lease for the readonly
device, returning an error so the machine starts to fail
The attached patch rejects passing readonly and shared devices
to the lock-plugin so they shouldn't be a problem anymore.
Would this be an appropriated way to fix this problem? (I'm
neither experienced in libvirt nor C)
What seems odd to me is that Fedora either doesn't hit this
or nobody has ever reported it.
I'm not member of this list so please CC me.
Thanks!
Cheers,
David
12 years, 8 months
[libvirt] Libvirt java binding crash Tomcat
by Hubert Zhang
Running on linux and libvirt 0.9.11. Using libvirt java 0.4.7. Notice that the Tomcat server crashes and shows the dump like this:
*** glibc detected *** jsvc.exec: double free or corruption (out): 0x086f14a8 ***
======= Backtrace: =========
/lib/libc.so.6[0xc03745]
/lib/libc.so.6(cfree+0x59)[0xc03b89]
/tmp/jna/jna486823639517928939.tmp(Java_com_sun_jna_Native_free+0x1d)[0x430c4c]
[0xb46de240]
[0xb46d218d]
[0xb46d218d]
[0xb46d218d]
[0xb46cf3e6]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13bdb21]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x15b3478]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13bd94f]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13f0ef7]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13d4aee]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/libjava.so(Java_java_lang_ref_Finalizer_invokeFinalizeMethod+0x6e)[0x11cb3e]
[0xb46de240]
[0xb46d218d]
[0xb46d218d]
[0xb46d218d]
[0xb46cf3e6]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13bdb21]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x15b3478]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13bd395]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x13bd458]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x143fbe7]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x16b404f]
/usr/lib/jvm/sun-java-6u24/jre/lib/i386/server/libjvm.so[0x15b4a6e]
/lib/libpthread.so.0[0x8fa842]
/lib/libc.so.6(clone+0x5e)[0xc6c4ce]
======= Memory map: ========
00110000-00133000 r-xp 00000000 08:01 106948 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libjava.so
00133000-00135000 rw-p 00023000 08:01 106948 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libjava.so
00135000-00148000 r-xp 00000000 08:01 74629 /lib/libnsl-2.5.so
00148000-00149000 r--p 00012000 08:01 74629 /lib/libnsl-2.5.so
00149000-0014a000 rw-p 00013000 08:01 74629 /lib/libnsl-2.5.so
0014a000-0014c000 rw-p 00000000 00:00 0
0014c000-0014f000 ---p 00000000 00:00 0
0014f000-0019d000 rwxp 00000000 00:00 0
0019d000-001d7000 r-xp 00000000 08:01 106944 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libjdwp.so
001d7000-001d8000 rw-p 00039000 08:01 106944 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libjdwp.so
001d8000-001d9000 ---p 00000000 00:00 0
001d9000-00259000 rwxp 00000000 00:00 0
00259000-0026d000 r-xp 00000000 08:01 106885 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libnet.so
0026d000-0026e000 rw-p 00013000 08:01 106885 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/libnet.so
0026e000-00273000 r-xp 00000000 08:01 106769 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/headless/libmawt.so
00273000-00274000 rw-p 00004000 08:01 106769 /usr/lib/jvm/sun-java-6u24/jre/lib/i386/headless/libmawt.so
00276000-00290000 r-xp 00000000 08:01 74651 /lib/ld-2.5.so
00290000-00291000 r--p 00019000 08:01 74651 /lib/ld-2.5.so
00291000-00292000 rw-p 0001a000 08:01 74651 /lib/ld-2.5.so
00292000-00295000 ---p 00000000 00:00 0
00295000-002e3000 rwxp 00000000 00:00 0
002e3000-002e8000 r-xp 00000000 08:01 212038 /usr/lib/libwsman_curl_client_transport.so.1.0.0
002e8000-002e9000 rw-p 00004000 08:01 212038 /usr/lib/libwsman_curl_client_transport.so.1.0.0
......................................
Sometimes I see "invalid pointer" as well. It seems a bug to the libvirt java API. Has anyone seen this error before? Thanks.
12 years, 8 months
[libvirt] oVirt workshop at LinuxCon Japan
by Dave Allan
I got this notice today about an oVirt workshop coming up June 8 at
LinuxCon Japan, and I thought it might be of interest. Details
below...
Hello everyone,
As part of our efforts to raise awareness of and educate more
developers about the oVirt project, we will be holding an oVirt
workshop at LinuxCon Japan, taking place on June 8, 2012. You can find
full details of the workshop agenda on the LinuxCon Japan site. [0]
Registration for the workshop is now open and is free of charge for
the first 50 participants. We will also look at adding additional
participant slots to the workshop based on demand.
Attendees who register for LinuxCon Japan via the workshop
registration link [1] will also be eligible for a discount on their
LinuxCon Japan registration.
Please spread the word to folks you think would find the workshop
useful. If they have already registered for LinuxCon Japan, they can
simply edit their existing registration to include the workshop.
[0]
https://events.linuxfoundation.org/events/linuxcon-japan/ovirt-gluster-wo...
[1]
http://www.regonline.com/Register/Checkin.aspx?EventID=1099949
Cheers,
LH
--
Leslie Hawthorn
Community Action and Impact
Open Source and Standards @ Red Hat
identi.ca/lh
twitter.com/lhawthorn
12 years, 8 months
[libvirt] [PATCH-RFC] Change libxl to use Xen 4.2 interface
by Daniel De Graaf
This patch changes libxl to use the interface in Xen 4.2. It is provided
as an example, not intended to go in to libvirt as-is since it removes
all support for libxl from Xen 4.1. It also still has some cruft (extra
void casts on parameters) and the device model info population is not
written. It has been tested with simple domain create/destroy.
---
src/libxl/libxl_conf.c | 134 +++++++++------
src/libxl/libxl_conf.h | 8 +-
src/libxl/libxl_driver.c | 430 ++++++++++++++++++++++++++--------------------
3 files changed, 326 insertions(+), 246 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 62621f1..c5b5561 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -41,7 +41,7 @@
#include "capabilities.h"
#include "libxl_driver.h"
#include "libxl_conf.h"
-
+#include "libxl_utils.h"
#define VIR_FROM_THIS VIR_FROM_LIBXL
@@ -358,18 +358,29 @@ 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->seclabel.type == VIR_DOMAIN_SECLABEL_STATIC) {
+ if (libxl_flask_context_to_sid(driver->ctx, def->seclabel.label, strlen(def->seclabel.label), &c_info->ssidref)) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxenlight failed to resolve security label '%s'"), def->seclabel.label);
+ }
+ }
+
virUUIDFormat(def->uuid, uuidstr);
if (libxl_uuid_from_string(&c_info->uuid, uuidstr) ) {
libxlError(VIR_ERR_INTERNAL_ERROR,
@@ -380,7 +391,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;
}
@@ -403,9 +414,9 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
return -1;
}
- libxl_init_build_info(b_info, &d_config->c_info);
+ libxl_domain_build_info_init(b_info);
- b_info->hvm = hvm;
+ b_info->type = hvm ? LIBXL_DOMAIN_TYPE_HVM : LIBXL_DOMAIN_TYPE_PV;
b_info->max_vcpus = def->maxvcpus;
if (def->vcpus == 32)
b_info->cur_vcpus = (uint32_t) -1;
@@ -424,16 +435,17 @@ 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);
}
}
@@ -454,7 +466,14 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
}
}
if (def->os.bootloaderArgs) {
- if ((b_info->u.pv.bootloader_args = strdup(def->os.bootloaderArgs)) == NULL) {
+ // XXX may need to split these arguments on a delimiter
+ b_info->u.pv.bootloader_args = malloc(sizeof(char*));
+ if (b_info->u.pv.bootloader_args == NULL) {
+ virReportOOMError();
+ goto error;
+ }
+ b_info->u.pv.bootloader_args[0] = strdup(def->os.bootloaderArgs);
+ if (b_info->u.pv.bootloader_args[0] == NULL) {
virReportOOMError();
goto error;
}
@@ -467,8 +486,8 @@ 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.path);
+ if ((b_info->u.pv.kernel.path = strdup(def->os.kernel)) == NULL) {
virReportOOMError();
goto error;
}
@@ -484,7 +503,7 @@ 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;
}
@@ -507,30 +526,30 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
STREQ(l_disk->driverName, "tap2")) {
if (l_disk->driverType) {
if (STREQ(l_disk->driverType, "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;
} else if (STREQ(l_disk->driverType, "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;
} else if (STREQ(l_disk->driverType, "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;
} else if (STREQ(l_disk->driverType, "aio") ||
STREQ(l_disk->driverType, "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;
}
} else {
/* No subtype specified, 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;
}
} 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 {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight does not support disk driver %s"),
@@ -538,13 +557,14 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
return -1;
}
} else {
- /* No driverName - default to raw/tap?? */
- x_disk->format = DISK_FORMAT_RAW;
- x_disk->backend = DISK_BACKEND_TAP;
+
+ /* No driverName - default to raw/phy?? */
+ x_disk->format = LIBXL_DISK_FORMAT_RAW;
+ x_disk->backend = LIBXL_DISK_BACKEND_PHY;
}
- /* 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) {
@@ -553,7 +573,7 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
return -1;
}
- x_disk->domid = def->id;
+ (void)def->id;
return 0;
}
@@ -583,7 +603,7 @@ 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;
}
@@ -595,7 +615,7 @@ libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic,
// TODO: Where is mtu stored?
//x_nics[i].mtu = 1492;
- x_nic->domid = def->id;
+ (void)def->id;
memcpy(x_nic->mac, l_nic->mac, sizeof(libxl_mac));
if (l_nic->model && !STREQ(l_nic->model, "netfront")) {
@@ -603,9 +623,9 @@ libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic,
virReportOOMError();
return -1;
}
- x_nic->nictype = NICTYPE_IOEMU;
+ x_nic->nictype = LIBXL_NIC_TYPE_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) {
@@ -663,7 +683,7 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
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;
}
@@ -677,23 +697,23 @@ libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
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) {
@@ -703,13 +723,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;
}
@@ -722,7 +742,7 @@ libxlMakeVfb(libxlDriverPrivatePtr driver, virDomainDefPtr def,
}
break;
}
- x_vfb->domid = def->id;
+ (void) def->id;
return 0;
}
@@ -750,8 +770,8 @@ 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)
goto error;
@@ -765,14 +785,15 @@ 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;
}
+#if 0
static int
libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
{
@@ -906,6 +927,7 @@ error:
libxl_device_model_info_destroy(dm_info);
return -1;
}
+#endif
virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx)
@@ -940,7 +962,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) {
@@ -959,9 +981,11 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
goto error;
}
+#if 0
if (libxlMakeDeviceModelInfo(def, d_config) < 0) {
goto error;
}
+#endif
d_config->on_reboot = def->onReboot;
d_config->on_poweroff = def->onPoweroff;
@@ -970,6 +994,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 2820afb..73ab733 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"
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 45bf1f8..8656f35 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"
@@ -79,6 +80,138 @@ libxlDriverUnlock(libxlDriverPrivatePtr driver)
virMutexUnlock(&driver->lock);
}
+struct libxl_osevent_hook_fdinfo {
+ libxlDomainObjPrivatePtr priv;
+ void *xl_priv;
+ int watch;
+};
+
+static void cb_fd_event(int watch, int fd, int vir_events, void *fdinfo)
+{
+ struct libxl_osevent_hook_fdinfo *info = fdinfo;
+ int events = 0;
+ (void)watch; (void)fd;
+ 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 free_fdinfo(void *opaque)
+{
+ free(opaque);
+}
+
+static int evhook_fd_register(void *priv, int fd, void **hndp, short events, void *xl_priv)
+{
+ int vir_events = VIR_EVENT_HANDLE_ERROR;
+ struct libxl_osevent_hook_fdinfo *fdinfo;
+ fdinfo = malloc(sizeof(fdinfo));
+ 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, cb_fd_event, fdinfo, free_fdinfo);
+ if (fdinfo->watch < 0)
+ return fdinfo->watch;
+ return 0;
+}
+
+static int evhook_fd_modify(void *priv, int fd, void **hndp, short events)
+{
+ struct libxl_osevent_hook_fdinfo *fdinfo = *hndp;
+ (void)fd; (void)priv;
+ 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 evhook_fd_deregister(void *priv, int fd, void *hnd)
+{
+ struct libxl_osevent_hook_fdinfo *fdinfo = hnd;
+ (void)priv; (void)fd;
+ virEventRemoveHandle(fdinfo->watch);
+}
+
+struct libxl_osevent_hook_timerinfo {
+ libxlDomainObjPrivatePtr priv;
+ void *xl_priv;
+ int id;
+};
+
+
+static void cb_timer(int timer, void *timer_v)
+{
+ struct libxl_osevent_hook_timerinfo *timer_info = timer_v;
+ (void)timer;
+ libxl_osevent_occurred_timeout(timer_info->priv->ctx, timer_info->xl_priv);
+}
+
+static void timer_info_free(void* obj)
+{
+ free(obj);
+}
+
+static int evhook_timeout_register(void *priv, void **hndp, struct timeval abs_t, void *for_libxl)
+{
+ struct timeval now;
+ struct libxl_osevent_hook_timerinfo *timer_info;
+ int timeout, timer_id;
+ timer_info = malloc(sizeof(*timer_info));
+ 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, cb_timer, timer_info, timer_info_free);
+ if (timer_id < 0)
+ 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 evhook_timeout_modify(void *priv, void **hndp, struct timeval abs_t)
+{
+ struct timeval now;
+ int timeout;
+ struct libxl_osevent_hook_timerinfo *timer_info = *hndp;
+ (void)priv;
+ 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 evhook_timeout_deregister(void *priv, void *hnd) {
+ struct libxl_osevent_hook_timerinfo *timer_info = hnd;
+ virEventRemoveTimeout(timer_info->id);
+ (void)priv;
+}
+
+static const libxl_osevent_hooks event_callbacks = {
+ .fd_register = evhook_fd_register,
+ .fd_modify = evhook_fd_modify,
+ .fd_deregister = evhook_fd_deregister,
+ .timeout_register = evhook_timeout_register,
+ .timeout_modify = evhook_timeout_modify,
+ .timeout_deregister = evhook_timeout_deregister,
+};
+
static void *
libxlDomainObjPrivateAlloc(void)
{
@@ -87,9 +220,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, &event_callbacks, priv);
return priv;
}
@@ -99,16 +232,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);
}
@@ -120,17 +249,6 @@ libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
virDomainEventStateQueue(driver->domainEventState, event);
}
-/*
- * Remove reference to domain object.
- */
-static void
-libxlDomainObjUnref(void *data)
-{
- virDomainObjPtr vm = data;
-
- ignore_value(virDomainObjUnref(vm));
-}
-
static void
libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
void *opaque)
@@ -161,13 +279,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)) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxl_get_version_info failed"));
return -1;
@@ -291,15 +409,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) {
@@ -350,12 +462,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) < 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Unable to cleanup domain %d"), vm->def->id);
return -1;
@@ -368,56 +479,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);
@@ -425,18 +506,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;
}
}
@@ -449,9 +530,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.
@@ -460,40 +546,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_event_register_callbacks(priv->ctx, &ev_hooks, vm);
- libxl_get_wait_fd(&priv->ctx, &fd);
- if (fd < 0)
+ if (libxl_evenable_domain_death(priv->ctx, vm->def->id, 0, &priv->deathW))
goto error;
- priv->waiterFD = fd;
- /* Add a reference to the domain object while it is injected in
- * the event loop.
- */
- virDomainObjRef(vm);
- if ((priv->eventHdl = virEventAddHandle(
- fd,
- VIR_EVENT_HANDLE_READABLE | VIR_EVENT_HANDLE_ERROR,
- libxlEventHandler,
- vm, libxlDomainObjUnref)) < 0) {
- ignore_value(virDomainObjUnref(vm));
- 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);
+ free(priv->deathW);
return -1;
}
@@ -534,7 +598,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
@@ -560,11 +624,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) {
@@ -572,17 +635,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;
}
}
@@ -651,7 +714,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;
@@ -664,10 +727,10 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
}
if (restore_fd < 0)
- ret = libxl_domain_create_new(&priv->ctx, &d_config,
+ ret = libxl_domain_create_new(priv->ctx, &d_config,
NULL, &child_console_pid, &domid);
else
- ret = libxl_domain_create_restore(&priv->ctx, &d_config, NULL,
+ ret = libxl_domain_create_restore(priv->ctx, &d_config, NULL,
&child_console_pid, &domid,
restore_fd);
@@ -687,7 +750,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)) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to store userdata"));
@@ -701,7 +764,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);
@@ -717,18 +780,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);
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);
@@ -756,7 +819,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) {
@@ -766,7 +829,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;
@@ -804,7 +867,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);
@@ -937,14 +1000,14 @@ libxlStartup(int 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;
}
@@ -952,7 +1015,7 @@ libxlStartup(int 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;
}
@@ -1112,7 +1175,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)
@@ -1317,7 +1380,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to suspend domain '%d' with libxenlight"),
dom->id);
@@ -1376,7 +1439,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to resume domain '%d' with libxenlight"),
dom->id);
@@ -1433,7 +1496,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to shutdown domain '%d' with libxenlight"),
dom->id);
@@ -1486,7 +1549,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to reboot domain '%d' with libxenlight"),
dom->id);
@@ -1531,7 +1594,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), dom->id);
goto cleanup;
@@ -1669,7 +1732,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set maximum memory for domain '%d'"
" with libxenlight"), dom->id);
@@ -1698,7 +1761,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set memory for domain '%d'"
@@ -1758,7 +1821,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxl_domain_info failed for domain '%d'"), dom->id);
goto cleanup;
@@ -1858,7 +1921,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, NULL, vm->def->id, fd) != 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to save domain '%d' with libxenlight"),
vm->def->id);
@@ -1868,7 +1931,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), vm->def->id);
goto cleanup;
@@ -2023,7 +2086,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Before dumping core, failed to suspend domain '%d'"
" with libxenlight"),
@@ -2034,7 +2097,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) != 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to dump core of domain '%d' with libxenlight"),
dom->id);
@@ -2043,7 +2106,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), dom->id);
goto cleanup_unlock;
@@ -2064,7 +2127,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("After dumping core, failed to resume domain '%d' with"
" libxenlight"), dom->id);
@@ -2301,7 +2364,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
" with libxenlight"), dom->id);
@@ -2310,7 +2373,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
" with libxenlight"), dom->id);
@@ -2427,7 +2490,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
@@ -2479,7 +2542,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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to list vcpus for domain '%d' with libxenlight"),
@@ -2506,7 +2569,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);
@@ -2564,7 +2627,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;
}
@@ -2607,7 +2670,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;
}
@@ -2870,7 +2933,7 @@ libxlDomainChangeEjectableMedia(libxlDomainObjPrivatePtr priv,
if (libxlMakeDisk(vm->def, 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)) < 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to change media for disk '%s'"),
disk->dst);
@@ -2925,7 +2988,7 @@ libxlDomainAttachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
if (libxlMakeDisk(vm->def, l_disk, &x_disk) < 0)
goto cleanup;
- if ((ret = libxl_device_disk_add(&priv->ctx, vm->def->id,
+ if ((ret = libxl_device_disk_add(priv->ctx, vm->def->id,
&x_disk)) < 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to attach disk '%s'"),
@@ -2959,7 +3022,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) {
@@ -2979,8 +3041,7 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
if (libxlMakeDisk(vm->def, 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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to detach disk '%s'"),
l_disk->dst);
@@ -3355,12 +3416,12 @@ 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)) {
libxlError(VIR_ERR_INTERNAL_ERROR, _("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) {
libxlError(VIR_ERR_INTERNAL_ERROR, _("libxl_get_version_info failed"));
return 0;
}
@@ -3506,7 +3567,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);
@@ -3523,31 +3584,29 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
}
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- libxlError(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:
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to get scheduler id for domain '%d'"
+ " with libxenlight"), dom->id);
goto cleanup;
}
@@ -3566,11 +3625,16 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
int *nparams,
unsigned int flags)
{
+ (void)dom;
+ (void)params;
+ (void)nparams;
+ (void)flags;
+
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
- libxl_sched_credit sc_info;
- int sched_id;
+ libxl_sched_credit_domain sc_info;
+ libxl_scheduler sched_id;
int ret = -1;
virCheckFlags(0, -1);
@@ -3591,20 +3655,15 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- libxlError(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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
- if (libxl_sched_credit_domain_get(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_sched_credit_domain_get(priv->ctx, dom->id, &sc_info) != 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
@@ -3644,10 +3703,14 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
int nparams,
unsigned int flags)
{
+ (void)dom;
+ (void)params;
+ (void)nparams;
+ (void)flags;
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm;
- libxl_sched_credit sc_info;
+ libxl_sched_credit_domain sc_info;
int sched_id;
int i;
int ret = -1;
@@ -3677,20 +3740,15 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
priv = vm->privateData;
- if ((sched_id = libxl_get_sched_id(&priv->ctx)) < 0) {
- libxlError(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) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
- if (libxl_sched_credit_domain_get(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_sched_credit_domain_get(priv->ctx, dom->id, &sc_info) != 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
@@ -3707,7 +3765,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
}
}
- if (libxl_sched_credit_domain_set(&priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_sched_credit_domain_set(priv->ctx, dom->id, &sc_info) != 0) {
libxlError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set scheduler parameters for domain '%d'"
" with libxenlight"), dom->id);
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] docs: mention migration issue of which credentials are used
by Eric Blake
Based on a report by Seth Vidal. Just because _you_ can use virsh
to connect to both source and destinations does not mean that libvirtd
on the source (aka _root_) can likewise connect to the destination;
this matters when setting up a peer-to-peer migration instead of a
native one.
* docs/migration.html.in: Mention that in peer-to-peer, the owner
of the source libvirtd (usually root) must be able to connect to
the destination.
---
docs/migration.html.in | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/docs/migration.html.in b/docs/migration.html.in
index 9d9d9b9..6a0483d 100644
--- a/docs/migration.html.in
+++ b/docs/migration.html.in
@@ -87,7 +87,13 @@
daemon controls the entire migration process itself, by directly
connecting the destination host libvirtd. If the client application crashes,
or otherwise loses its connection to libvirtd, the migration process
- will continue uninterrupted until completion.
+ will continue uninterrupted until completion. Note that the
+ source libvirtd uses its own credentials to connect to the
+ destination (typically root), rather than the credentials used
+ by the client to connect to the host; if these differ, it is
+ common to run into a situation where a client can connect to the
+ destination directly but the host cannot make the connection to
+ set up the peer-to-peer migration.
</p>
<p>
@@ -139,7 +145,9 @@
connection to the source host, where the virtual guest is
currently running. The second URI is that of the libvirt
connection to the destination host, where the virtual guest
- will be moved to. The third URI is a hypervisor specific
+ will be moved to (and in peer-to-peer migrations, this is from
+ the perspective of the source, not the client). The third URI is
+ a hypervisor specific
URI used to control how the guest will be migrated. With
any managed migration flow, the first and second URIs are
compulsory, while the third URI is optional. With the
@@ -533,7 +541,10 @@
destination libvirtd server will automatically determine
the native hypervisor URI for migration, based off the
primary hostname. There is no scope for forcing an alternative
- network interface for the native migration data with this method.
+ network interface for the native migration data with this
+ method. The destination URI must be reachable using the source
+ libvirtd credentials (which are not necessarily the same as the
+ credentials of the client in connecting to the source).
</p>
<pre>
@@ -571,7 +582,10 @@
in case it is not accessible using the same address that
the client uses to connect to the destination, or a different
encryption/auth scheme is required. The native hypervisor URI
- format is not used at all.
+ format is not used at all. The destination URI must be
+ reachable using the source libvirtd credentials (which are not
+ necessarily the same as the credentials of the client in
+ connecting to the source).
</p>
<pre>
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH libvirt 1/2] storage: add preallocation element
by Marc-André Lureau
Allow to specify preallocation mode for QCOW2 images.
If not specified or not available, it's ignored.
This change only modify the schema, doc, parsing and tests.
---
docs/formatstorage.html.in | 6 ++++++
docs/schemas/storagevol.rng | 18 ++++++++++++++++++
src/conf/storage_conf.c | 26 ++++++++++++++++++++++++++
src/conf/storage_conf.h | 1 +
src/util/storage_file.c | 4 ++++
src/util/storage_file.h | 10 ++++++++++
tests/storagevolxml2xmlin/vol-qcow2.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2.xml | 1 +
8 files changed, 67 insertions(+)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index d0e4319..c4faadf 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -252,6 +252,12 @@
1,152,921,504,606,846,976 bytes). <span class="since">Since
0.4.1, multi-character <code>unit</code> since
0.9.11</span></dd>
+ <dt><code>preallocation</code></dt>
+ <dd>An image with preallocated metadata is initially larger but
+ can improve performance when the image needs to grow. This is
+ supported by QCOW2 image format.
+ Attribe <code>mode</code> value can be 'off' or 'metadata'.
+ <span class="since">Since 0.9.13</span></dd>
<dt><code>capacity</code></dt>
<dd>Providing the logical capacity for the volume. This value is
in bytes by default, but a <code>unit</code> attribute can be
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 8edb877..d9a148e 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -40,6 +40,7 @@
<ref name='scaledInteger'/>
</element>
</optional>
+ <ref name='preallocation'/>
</define>
<define name='permissions'>
@@ -171,6 +172,23 @@
</optional>
</define>
+ <define name='preallocationmode'>
+ <choice>
+ <value>off</value>
+ <value>metadata</value>
+ </choice>
+ </define>
+
+ <define name='preallocation'>
+ <optional>
+ <element name='preallocation'>
+ <attribute name='mode'>
+ <ref name='preallocationmode'/>
+ </attribute>
+ </element>
+ </optional>
+ </define>
+
<define name='name'>
<data type='string'>
<param name="pattern">[a-zA-Z0-9_\+\-\.]+</param>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 0b34f28..95849ec 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -991,6 +991,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
char *allocation = NULL;
char *capacity = NULL;
char *unit = NULL;
+ char *preallocation = NULL;
xmlNodePtr node;
options = virStorageVolOptionsForPoolType(pool->type);
@@ -1035,6 +1036,19 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->allocation = ret->capacity;
}
+ preallocation = virXPathString("string(./preallocation/@mode)", ctxt);
+ if (preallocation) {
+ if ((ret->preallocation = virStoragePreallocationModeTypeFromString(preallocation)) < 0) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown preallocation mode %s"), preallocation);
+ goto cleanup;
+ }
+
+ VIR_FREE(preallocation);
+ } else {
+ ret->preallocation = VIR_STORAGE_PREALLOCATION_NONE;
+ }
+
ret->target.path = virXPathString("string(./target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString("string(./target/format/@type)", ctxt);
@@ -1244,6 +1258,18 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
virBufferAsprintf(&buf," <allocation unit='bytes'>%llu</allocation>\n",
def->allocation);
+ if (def->preallocation != VIR_STORAGE_PREALLOCATION_NONE) {
+ const char *preallocation;
+
+ preallocation = virStoragePreallocationModeTypeToString(def->preallocation);
+ if (!preallocation) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unexpected pool type"));
+ goto cleanup;
+ }
+ virBufferAsprintf(&buf," <preallocation mode='%s'/>\n", preallocation);
+ }
+
if (virStorageVolTargetDefFormat(options, &buf,
&def->target, "target") < 0)
goto cleanup;
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 9222c4a..c7c7af0 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -98,6 +98,7 @@ struct _virStorageVolDef {
virStorageVolSource source;
virStorageVolTarget target;
virStorageVolTarget backingStore;
+ int preallocation; /* virStoragePreallocationMode enum */
};
typedef struct _virStorageVolDefList virStorageVolDefList;
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 530071e..8d78d36 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -47,6 +47,10 @@ VIR_ENUM_IMPL(virStorageFileFormat,
"cloop", "cow", "dmg", "iso",
"qcow", "qcow2", "qed", "vmdk", "vpc")
+VIR_ENUM_IMPL(virStoragePreallocationMode,
+ VIR_STORAGE_PREALLOCATION_LAST,
+ "", "off", "metadata")
+
enum lv_endian {
LV_LITTLE_ENDIAN = 1, /* 1234 */
LV_BIG_ENDIAN /* 4321 */
diff --git a/src/util/storage_file.h b/src/util/storage_file.h
index 13d0e87..dfc8719 100644
--- a/src/util/storage_file.h
+++ b/src/util/storage_file.h
@@ -46,6 +46,16 @@ enum virStorageFileFormat {
VIR_ENUM_DECL(virStorageFileFormat);
+enum virStoragePreallocationMode {
+ VIR_STORAGE_PREALLOCATION_NONE,
+ VIR_STORAGE_PREALLOCATION_OFF,
+ VIR_STORAGE_PREALLOCATION_METADATA,
+
+ VIR_STORAGE_PREALLOCATION_LAST
+};
+
+VIR_ENUM_DECL(virStoragePreallocationMode);
+
typedef struct _virStorageFileMetadata {
char *backingStore;
int backingStoreFormat;
diff --git a/tests/storagevolxml2xmlin/vol-qcow2.xml b/tests/storagevolxml2xmlin/vol-qcow2.xml
index b4924de..b4c6522 100644
--- a/tests/storagevolxml2xmlin/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlin/vol-qcow2.xml
@@ -5,6 +5,7 @@
</source>
<capacity unit="G">5</capacity>
<allocation>294912</allocation>
+ <preallocation mode='metadata'/>
<target>
<path>/var/lib/libvirt/images/OtherDemo.img</path>
<format type='qcow2'/>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml
index 4490931..311c52e 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2.xml
@@ -5,6 +5,7 @@
</source>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
+ <preallocation mode='metadata'/>
<target>
<path>/var/lib/libvirt/images/OtherDemo.img</path>
<format type='qcow2'/>
--
1.7.10
12 years, 8 months
[libvirt] [PATCH 1/1] Assign spapr-vio bus address to ibmvscsi controller
by Li Zhang
ibmvscsi is based on spapr-vio bus address type.
It can't work on PCI bus. Now, it is still on
pci bus.
This patch is to assign spapr-vio address type
to ibmvscsi controller.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/qemu/qemu_command.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 117542f..3100f41 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2566,6 +2566,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
virBufferAddLit(&buf, "lsi");
break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
+ def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
virBufferAddLit(&buf, "spapr-vscsi");
break;
default:
--
1.7.9.5
12 years, 8 months