[libvirt] [PATCH 1/2] libxl: support syntax interface type=hostdev
Signed-off-by: Chunyan Liu cy...@suse.com --- src/libxl/libxl_conf.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 298c8a1..b7fed7f 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -921,25 +921,31 @@ static int libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config) { virDomainNetDefPtr *l_nics = def-nets; -int nnics = def-nnets; +size_t nnics = def-nnets; libxl_device_nic *x_nics; -size_t i; +size_t i, nvnics = 0; if (VIR_ALLOC_N(x_nics, nnics) 0) return -1; for (i = 0; i nnics; i++) { -if (libxlMakeNic(def, l_nics[i], x_nics[i])) +if (l_nics[i]-type == VIR_DOMAIN_NET_TYPE_HOSTDEV) +continue; + +if (libxlMakeNic(def, l_nics[i], x_nics[nvnics])) goto error; /* * The devid (at least right now) will not get initialized by * libxl in the setup case but is required for starting the * device-model. */ -if (x_nics[i].devid 0) -x_nics[i].devid = i; +if (x_nics[nvnics].devid 0) +x_nics[nvnics].devid = nvnics; + +nvnics++; } +VIR_SHRINK_N(x_nics, nnics, nnics - nvnics); d_config-nics = x_nics; d_config-num_nics = nnics; -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] update documentation of interface type='hostdev'
interface type='hostdev' managed='yes' is supported, but nowhere mentions 'managed' in interface type='hostdev' syntax. Update documentation to cover it. Signed-off-by: Chunyan Liu cy...@suse.com --- docs/formatdomain.html.in | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 4f19473..c3b9f5b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3510,7 +3510,7 @@ pre ... lt;devicesgt; -lt;interface type='hostdev'gt; +lt;interface type='hostdev' managed='yes'gt; lt;driver name='vfio'/gt; lt;sourcegt; lt;address type='pci' domain='0x' bus='0x00' slot='0x07' function='0x0'/gt; @@ -3523,6 +3523,18 @@ lt;/devicesgt; .../pre +p + Similar to the functionality of a standard lt;hostdevgt; device, + when codemanaged/code is yes, it is detached from the host + before being passed on to the guest, and reattached to the host + after the guest exits. If codemanaged/code is omitted or no, + the user is responsible to call codevirNodeDeviceDettach/code + (or codevirsh nodedev-dettach/code) before starting the guest + or hot-plugging the device, and codevirNodeDeviceReAttach/code + (or codevirsh nodedev-reattach/code) after hot-unplug or + stopping the guest. +/p + h5a name=elementsNICSMulticastMulticast tunnel/a/h5 -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Adjust size for qcow2/qed if not on sector boundary
On 05/07/2014 09:05 PM, John Ferlan wrote: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4bb4819..3e407d7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9421,6 +9421,7 @@ qemuDomainBlockResize(virDomainPtr dom, virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; int ret = -1, idx; +unsigned long long size_up; char *device = NULL; virDomainDiskDefPtr disk = NULL; @@ -9467,6 +9474,21 @@ qemuDomainBlockResize(virDomainPtr dom, } disk = vm-def-disks[idx]; +/* qcow2 and qed must be sized appropriately, so be sure our value + * is sized appropriately and will fit + */ +if (size != size_up +(disk-src.format == VIR_STORAGE_FILE_QCOW2 || + disk-src.format == VIR_STORAGE_FILE_QED)) { +if (size_up ULLONG_MAX) { This is always false. An OVERLy cautious check - I cannot remember what I was thinking about a month ago... I think this was the check can VIR_ROUND_UP provide an incorrect value. I can send a follow-up patch to remove those lines if that's desired. VIR_ROUND_UP can still overflow if the size was specified in bytes and is larger than ULLONG_MAX-511. This is unlikely to happen in the real world, but it would be nice to check for it. +virReportError(VIR_ERR_OVERFLOW, + _(size must be less than %llu KiB), + ULLONG_MAX / 1024); +goto endjob; +} +size = size_up; Just a nitpick: rounding it up unconditionally here would get rid of the temporary variable and have no effect on values specified without the BYTES flag. Only qcow2 and qed have this issue regarding needing to be on a 512 byte boundary. Since this is a generic routine I was limiting the rounding to the two types from the bz rather than taking a chance that some generic round up would cause some other issue. Or am I misinterpreting your comment? I meant unconditional on whether the size was specified in bytes or not, something like: if (qcow2 or qed) { size = VIR_ROUND_UP(size, 512); } Jan signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Configure virtio-scsi options via libvirt
On 10:08 Wed 07 May , Stefan Hajnoczi wrote: On Tue, May 06, 2014 at 04:13:50PM -0700, Mike Perez wrote: I would like be able to configure virtio-scsi options num_queues, max_sectors, and cmd_per_lun via libvirt. Are there any plans to have this support? Hi Mike, I'm not sure about the status of libvirt support for virtio-scsi options but in the meantime you can use qemu:commandline passthrough: http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html Stefan Thanks Stefan, My plan is to write the support in OpenStack, which unfortunately does not accept patches doing qemu passthrough: http://lists.openstack.org/pipermail/openstack-dev/2013-November/018551.html -- Mike Perez -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Configure virtio-scsi options via libvirt
Il 08/05/2014 09:24, Mike Perez ha scritto: On 10:08 Wed 07 May , Stefan Hajnoczi wrote: On Tue, May 06, 2014 at 04:13:50PM -0700, Mike Perez wrote: I would like be able to configure virtio-scsi options num_queues, max_sectors, and cmd_per_lun via libvirt. Are there any plans to have this support? Hi Mike, I'm not sure about the status of libvirt support for virtio-scsi options but in the meantime you can use qemu:commandline passthrough: http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html Stefan Thanks Stefan, My plan is to write the support in OpenStack, which unfortunately does not accept patches doing qemu passthrough: http://lists.openstack.org/pipermail/openstack-dev/2013-November/018551.html Why do you need such fine-grained control? The higher you go in the stack, the simpler configuration should be in my opinion. For openstack, I think all you need is a singlequeue vs. multiqueue knob (setting num_queues = # VCPUs for multiqueue). Paolo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Configure virtio-scsi options via libvirt
On Wed, May 07, 2014 at 10:24:54AM +0200, Ján Tomko wrote: On 05/07/2014 01:13 AM, Mike Perez wrote: Hi everyone, I would like be able to configure virtio-scsi options num_queues, max_sectors, and cmd_per_lun via libvirt. Are there any plans to have this support? num_queues is supported for virtio-scsi controllers since libvirt 1.0.5: If anyone wants to contribute patches for the other two properties I would not be a very difficult/large coding job to undertake. I'm not aware of anyone else who is currently working on it, so anyone please jump right in... Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] parallels: add VIR_STORAGE_FILE_PLOOP format
On Wed, May 07, 2014 at 10:04:06PM +0400, Dmitry Guryanov wrote: Add VIR_STORAGE_FILE_PLOOP format. This format is used to store disk images for virtual machines in PCS and containers in PCS, OpenVZ and also in Parallels Desktop for Mac. This format is described on OpenVZ site - https://openvz.org/Ploop (together with ploop devices). It consists of XML descriptor and one or more image files: base image and deltas. Format of the image files described here: https://openvz.org/Ploop/format. Hmm, so 'ploop' now refers to both a kernel device driver and also an image format ? I thought that historically 'ploop' was just a device driver, which in turn would support raw or qcow2, or blah image formats ? Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] parallels: add disks correctly
On Wed, May 07, 2014 at 10:04:08PM +0400, Dmitry Guryanov wrote: Disks support in this driver was implemented with an assumption, that disk images can't be created by hand, without VM. So complex storage driver was implemented with workaround. This is not true, we can create new disks using ploop tool. So the first step to reimplement disks support in parallels driver is to do not use information from the storage driver, until we will implement VIR_STORAGE_TYPE_VOLUME disks. So after this patch disks can be added in the same way as in any other driver: you create a disk image and then add an entry to the XML definition of the domain with path to that image file, for example: disk type='file' device='disk' driver type='ploop'/ source file='/storage/harddisk1.hdd'/ target dev='sda' bus='sata'/ address type='drive' controller='0' bus='0' target='0' unit='0'/ /disk This patch makes parallels storage driver useless, but I'll fix it later. Now you can create an image by hand, using ploop tool, and then add it to some domain. Signed-off-by: Dmitry Guryanov dgurya...@parallels.com --- src/parallels/parallels_driver.c | 83 ++-- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index b2de12f..67b28c4 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -1605,17 +1605,34 @@ parallelsApplyVideoParams(parallelsDomObjPtr pdom, return 0; } -static int parallelsAddHddByVolume(parallelsDomObjPtr pdom, - virDomainDiskDefPtr disk, - virStoragePoolObjPtr pool, - virStorageVolDefPtr voldef) +static int parallelsAddHdd(parallelsDomObjPtr pdom, + virDomainDiskDefPtr disk) { int ret = -1; +const char *src = virDomainDiskGetSource(disk); +int type = virDomainDiskGetType(disk); const char *strbus; virCommandPtr cmd = virCommandNewArgList(PRLCTL, set, pdom-uuid, --device-add, hdd, NULL); -virCommandAddArgFormat(cmd, --size=%lluM, voldef-target.capacity 20); + +if (type == VIR_STORAGE_TYPE_FILE) { +int format = virDomainDiskGetFormat(disk); + +if (format != VIR_STORAGE_FILE_PLOOP) +virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _(Invalid disk format: %d), type); Missing a 'goto cleanup' after reporting the error, so that execution returns + +virCommandAddArg(cmd, --image); +} else if (VIR_STORAGE_TYPE_BLOCK) { +virCommandAddArg(cmd, --device); +} else { +virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _(Invalid disk type: %d), type); +goto cleanup; +} + +virCommandAddArg(cmd, src); if (!(strbus = parallelsGetDiskBusName(disk-bus))) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, @@ -1632,54 +1649,10 @@ static int parallelsAddHddByVolume(parallelsDomObjPtr pdom, if (virCommandRun(cmd, NULL) 0) goto cleanup; Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] parallels: create VMs in the default place
On Wed, May 07, 2014 at 10:04:09PM +0400, Dmitry Guryanov wrote: Each VM consists of a set of files in PCS: config, hard disk images, log file, memory dump. All these files are stored in a per-vm directory. When we create a new VM, we can ether specify path to the VM or create the VM in a default path (default path/vm name.pvm). This default path can be configured with command prlsrvctl user set --def-vm-home path command. Currenty parallels driver creates VM in the same place, where first hard disk is located. Let's change this logic and create VMs in the default path. It will be much clearer and allow us to create VMs without hard disks. Signed-off-by: Dmitry Guryanov dgurya...@parallels.com --- src/parallels/parallels_driver.c | 63 ++-- 1 file changed, 3 insertions(+), 60 deletions(-) ACK Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] parallels: add VIR_STORAGE_FILE_PLOOP format
On Thursday 08 May 2014 10:43:41 Daniel P. Berrange wrote: On Wed, May 07, 2014 at 10:04:06PM +0400, Dmitry Guryanov wrote: Add VIR_STORAGE_FILE_PLOOP format. This format is used to store disk images for virtual machines in PCS and containers in PCS, OpenVZ and also in Parallels Desktop for Mac. This format is described on OpenVZ site - https://openvz.org/Ploop (together with ploop devices). It consists of XML descriptor and one or more image files: base image and deltas. Format of the image files described here: https://openvz.org/Ploop/format. Hmm, so 'ploop' now refers to both a kernel device driver and also an image format ? I thought that historically 'ploop' was just a device driver, which in turn would support raw or qcow2, or blah image formats ? Yes, you're right, we don't have any separate name for image format, so in man pages it's called ploop1 or expanded. Now ploop devices support only raw and ploop images. Regards, Daniel -- Dmitry Guryanov -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] parallels: add VIR_STORAGE_FILE_PLOOP format
On Wed, May 07, 2014 at 10:04:06PM +0400, Dmitry Guryanov wrote: Add VIR_STORAGE_FILE_PLOOP format. This format is used to store disk images for virtual machines in PCS and containers in PCS, OpenVZ and also in Parallels Desktop for Mac. This format is described on OpenVZ site - https://openvz.org/Ploop (together with ploop devices). It consists of XML descriptor and one or more image files: base image and deltas. Format of the image files described here: https://openvz.org/Ploop/format. This patch only adds VIR_STORAGE_FILE_PLOOP constant, consequent patches will use it in parallels driver. Signed-off-by: Dmitry Guryanov dgurya...@parallels.com --- src/util/virstoragefile.c | 4 +++- src/util/virstoragefile.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 96af27b..5c1ab62 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -62,7 +62,7 @@ VIR_ENUM_IMPL(virStorageFileFormat, cloop, dmg, iso, vpc, vdi, /* Not direct file formats, but used for various drivers */ - fat, vhd, + fat, vhd, ploop, /* Formats with backing file below here */ cow, qcow, qcow2, qed, vmdk) @@ -230,6 +230,8 @@ static struct FileTypeInfo const fileTypeInfo[] = { -1, {0}, 0, 0, 0, 0, NULL, NULL }, [VIR_STORAGE_FILE_VHD] = { 0, NULL, NULL, LV_LITTLE_ENDIAN, -1, {0}, 0, 0, 0, 0, NULL, NULL }, +[VIR_STORAGE_FILE_PLOOP] = { 0, NULL, NULL, LV_LITTLE_ENDIAN, + -1, {0}, 0, 0, 0, 0, NULL, NULL }, Is there no magic byte sequence to identify the ploop image format ? ACK if there is none. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] parallels: add VIR_STORAGE_FILE_PLOOP format
On Thursday 08 May 2014 11:58:22 Daniel P. Berrange wrote: On Wed, May 07, 2014 at 10:04:06PM +0400, Dmitry Guryanov wrote: Add VIR_STORAGE_FILE_PLOOP format. This format is used to store disk images for virtual machines in PCS and containers in PCS, OpenVZ and also in Parallels Desktop for Mac. This format is described on OpenVZ site - https://openvz.org/Ploop (together with ploop devices). It consists of XML descriptor and one or more image files: base image and deltas. Format of the image files described here: https://openvz.org/Ploop/format. This patch only adds VIR_STORAGE_FILE_PLOOP constant, consequent patches will use it in parallels driver. Signed-off-by: Dmitry Guryanov dgurya...@parallels.com --- src/util/virstoragefile.c | 4 +++- src/util/virstoragefile.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 96af27b..5c1ab62 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -62,7 +62,7 @@ VIR_ENUM_IMPL(virStorageFileFormat, cloop, dmg, iso, vpc, vdi, /* Not direct file formats, but used for various drivers */ - fat, vhd, + fat, vhd, ploop, /* Formats with backing file below here */ cow, qcow, qcow2, qed, vmdk) @@ -230,6 +230,8 @@ static struct FileTypeInfo const fileTypeInfo[] = { -1, {0}, 0, 0, 0, 0, NULL, NULL }, [VIR_STORAGE_FILE_VHD] = { 0, NULL, NULL, LV_LITTLE_ENDIAN, -1, {0}, 0, 0, 0, 0, NULL, NULL }, +[VIR_STORAGE_FILE_PLOOP] = { 0, NULL, NULL, LV_LITTLE_ENDIAN, + -1, {0}, 0, 0, 0, 0, NULL, NULL }, Is there no magic byte sequence to identify the ploop image format ? It refers to a directory with DiskDescriptor.xml file, base image and possibly some deltas. So it's not a file format. ACK if there is none. Regards, Daniel -- Dmitry Guryanov -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] Add invariant TSC cpu flag
Add suport for invariant TSC flag (CPUID 0x8007, bit 8 of EDX). If this flag is enabled, the TSC ticks at a constant rate across all ACPI P-, C- and T-states. This can be enabled by adding: feature name='invtsc'/ to the cpu element. Migration and saving the domain does not work with this flag. QEMU support for this is not merged yet: https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg05024.html The feature name invtsc differs from the name used by the linux kernel: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/cpu/powerflags.c?id=30321c7b#n18 --- v1: https://www.redhat.com/archives/libvir-list/2014-May/msg00183.html src/cpu/cpu_map.xml | 5 + src/qemu/qemu_migration.c | 14 ++ 2 files changed, 19 insertions(+) diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml index 7d34d40..ffaeb92 100644 --- a/src/cpu/cpu_map.xml +++ b/src/cpu/cpu_map.xml @@ -327,6 +327,11 @@ cpuid function='0x0007' ebx='0x0010'/ /feature +!-- Advanced Power Management edx features -- +feature name='invtsc' + cpuid function='0x8007' edx='0x0100'/ +/feature + !-- models -- model name='486' feature name='fpu'/ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a9f7fea..9ae3047 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1513,6 +1513,20 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm, return false; } +for (i = 0; i def-cpu-nfeatures; i++) { +virCPUFeatureDefPtr feature = def-cpu-features[i]; + +if (feature-policy != VIR_CPU_FEATURE_REQUIRE) +continue; + +if (STREQ(feature-name, invtsc)) { +virReportError(VIR_ERR_OPERATION_INVALID, + _(domain has CPU feature: %s), + feature-name); +return false; +} +} + return true; } -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Adjust size for qcow2/qed if not on sector boundary (rewrite)
A post commit id 'e3d66229' review (and followup): http://www.redhat.com/archives/libvir-list/2014-May/msg00268.html noted some issues with the code, so I have adjusted the code accordingly. The difference between this and the commit prior to the change (commit id 'f3be5f0c') will just be the check for qcow2/qed using a non 512 block aligned size will result in a round up of size. If the size is within the last 512 bytes to ULLONG_MAX, then just set it there rather than erroring out. Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_driver.c | 28 +--- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4ff8a2d..8771cae 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9413,7 +9413,6 @@ qemuDomainBlockResize(virDomainPtr dom, virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; int ret = -1, idx; -unsigned long long size_up; char *device = NULL; virDomainDiskDefPtr disk = NULL; @@ -9434,12 +9433,6 @@ qemuDomainBlockResize(virDomainPtr dom, return -1; } size *= 1024; -size_up = size; -} else { -/* For 'qcow2' and 'qed', qemu resize blocks expects values - * on sector boundary, so round our value up to prepare - */ -size_up = VIR_ROUND_UP(size, 512); } if (!(vm = qemuDomObjFromDomain(dom))) @@ -9466,19 +9459,16 @@ qemuDomainBlockResize(virDomainPtr dom, } disk = vm-def-disks[idx]; -/* qcow2 and qed must be sized appropriately, so be sure our value - * is sized appropriately and will fit +/* qcow2 and qed must be sized on 512 byte blocks/sectors, + * so adjust size if necessary to round up (if possible). */ -if (size != size_up -(disk-src.format == VIR_STORAGE_FILE_QCOW2 || - disk-src.format == VIR_STORAGE_FILE_QED)) { -if (size_up ULLONG_MAX) { -virReportError(VIR_ERR_OVERFLOW, - _(size must be less than %llu KiB), - ULLONG_MAX / 1024); -goto endjob; -} -size = size_up; +if ((disk-src.format == VIR_STORAGE_FILE_QCOW2 || + disk-src.format == VIR_STORAGE_FILE_QED) +(size % 512)) { +if ((ULLONG_MAX - size) 512) +size = ULLONG_MAX; +else +size = VIR_ROUND_UP(size, 512); } if (virAsprintf(device, %s%s, QEMU_DRIVE_HOST_PREFIX, -- 1.9.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH V7] libxl: add migration support
This patch adds initial migration support to the libxl driver, using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration functions. Signed-off-by: Jim Fehlig jfeh...@suse.com --- V6 here https://www.redhat.com/archives/libvir-list/2014-May/msg00017.html In V7: There were no comments on V6, but during testing I noticed that 'virsh migrate --suspend ...' was not being honored. Fixed that in this version so that the domain is paused on the destination once migration completes. po/POTFILES.in | 1 + src/Makefile.am | 3 +- src/libxl/libxl_conf.h | 6 + src/libxl/libxl_domain.h| 1 + src/libxl/libxl_driver.c| 235 ++ src/libxl/libxl_migration.c | 581 src/libxl/libxl_migration.h | 79 ++ 7 files changed, 905 insertions(+), 1 deletion(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index e35eb82..a72dc1e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -73,6 +73,7 @@ src/lxc/lxc_process.c src/libxl/libxl_domain.c src/libxl/libxl_driver.c src/libxl/libxl_conf.c +src/libxl/libxl_migration.c src/network/bridge_driver.c src/network/bridge_driver_linux.c src/node_device/node_device_driver.c diff --git a/src/Makefile.am b/src/Makefile.am index e9dc9e0..0dbda7f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -706,7 +706,8 @@ XENAPI_DRIVER_SOURCES = \ LIBXL_DRIVER_SOURCES = \ libxl/libxl_conf.c libxl/libxl_conf.h \ libxl/libxl_domain.c libxl/libxl_domain.h \ - libxl/libxl_driver.c libxl/libxl_driver.h + libxl/libxl_driver.c libxl/libxl_driver.h \ + libxl/libxl_migration.c libxl/libxl_migration.h UML_DRIVER_SOURCES = \ uml/uml_conf.c uml/uml_conf.h \ diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index 24e1720..b798567 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -43,6 +43,9 @@ # define LIBXL_VNC_PORT_MIN 5900 # define LIBXL_VNC_PORT_MAX 65535 +# define LIBXL_MIGRATION_PORT_MIN 49152 +# define LIBXL_MIGRATION_PORT_MAX 49216 + # define LIBXL_CONFIG_DIR SYSCONFDIR /libvirt/libxl # define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR /autostart # define LIBXL_STATE_DIR LOCALSTATEDIR /run/libvirt/libxl @@ -115,6 +118,9 @@ struct _libxlDriverPrivate { /* Immutable pointer, self-locking APIs */ virPortAllocatorPtr reservedVNCPorts; +/* Immutable pointer, self-locking APIs */ +virPortAllocatorPtr migrationPorts; + /* Immutable pointer, lockless APIs*/ virSysinfoDefPtr hostsysinfo; }; diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 979ce2a..9d48049 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -69,6 +69,7 @@ struct _libxlDomainObjPrivate { virChrdevsPtr devs; libxl_evgen_domain_death *deathW; libxlDriverPrivatePtr driver; +unsigned short migrationPort; struct libxlDomainJobObj job; }; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index df7d510..35467ac 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -45,6 +45,7 @@ #include libxl_domain.h #include libxl_driver.h #include libxl_conf.h +#include libxl_migration.h #include xen_xm.h #include xen_sxpr.h #include virtypedparam.h @@ -209,6 +210,7 @@ libxlStateCleanup(void) virObjectUnref(libxl_driver-xmlopt); virObjectUnref(libxl_driver-domains); virObjectUnref(libxl_driver-reservedVNCPorts); +virObjectUnref(libxl_driver-migrationPorts); virObjectEventStateFree(libxl_driver-domainEventState); virSysinfoDefFree(libxl_driver-hostsysinfo); @@ -301,6 +303,13 @@ libxlStateInitialize(bool privileged, LIBXL_VNC_PORT_MAX))) goto error; +/* Allocate bitmap for migration port reservation */ +if (!(libxl_driver-migrationPorts = + virPortAllocatorNew(_(migration), + LIBXL_MIGRATION_PORT_MIN, + LIBXL_MIGRATION_PORT_MAX))) +goto error; + if (!(libxl_driver-domains = virDomainObjListNew())) goto error; @@ -4155,6 +4164,7 @@ libxlConnectSupportsFeature(virConnectPtr conn, int feature) switch (feature) { case VIR_DRV_FEATURE_TYPED_PARAM_STRING: +case VIR_DRV_FEATURE_MIGRATION_PARAMS: return 1; default: return 0; @@ -4333,6 +4343,226 @@ libxlNodeDeviceReset(virNodeDevicePtr dev) return ret; } +static char * +libxlDomainMigrateBegin3Params(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + char **cookieout ATTRIBUTE_UNUSED, + int *cookieoutlen ATTRIBUTE_UNUSED, +