[libvirt] [PATCH v2 0/3] Update VRDE server port handling.

2017-10-24 Thread Dawid Zamirski
v1: https://www.redhat.com/archives/libvir-list/2017-October/msg00421.html Changes since v1: * separate out the patch that drops VBOX_SESSION_OPEN/CLOSE macros. * reverse logic to check for rdp.autoport instead of rdp.port to avoid handling port = -1 * do not set rdp.port = -1 if

[libvirt] [PATCH v2 1/3] vbox: Remove old unflexible macros

2017-10-24 Thread Dawid Zamirski
The VBOX_SESSION_OPEN/CLOSE macros are only called in _vboxDomainSnapshotRestore and they are unflexible because: * assume the caller will have variable named "data" * can only create Write lock type As per above, it's not that hard to simply use the VBOX API directly. --- src/vbox/vbox_tmpl.c

[libvirt] [PATCH v2 2/3] vbox: Make autoport set RDP port range.

2017-10-24 Thread Dawid Zamirski
From: Dawid Zamirski Originally autoport in vbox driver was setting the port to default value (3389) which caused multiple VM instances use the same port. Since libvirt XML does not allow to set port ranges, this patch changes the "autoport" behavior to set VBox's "TCP/Ports"

[libvirt] [PATCH v2 3/3] vbox: Read runtime RDP port and handle autoport

2017-10-24 Thread Dawid Zamirski
VirutalBox has a IVRDEServerInfo structure available that gives the effective runtime port that the VM is using when it's running. This is useful when the "TCP/Ports" VBox property was set to port range (e.g. via autoport = "yes" or via VBoxManage) in which case it would be impossible to get the

[libvirt] [PATCH v2 13/15] vbox: Cleanup vboxDumpDisks implementation

2017-10-24 Thread Dawid Zamirski
Primer the code for further changes: * move variable declarations to the top of the function * group together free/release statements * error check and report VBOX API calls used --- src/vbox/vbox_common.c | 188 +++-- 1 file changed, 120

[libvirt] [PATCH v2 11/15] vbox: Add vboxDumpStorageControllers

2017-10-24 Thread Dawid Zamirski
--- src/vbox/vbox_common.c | 119 + 1 file changed, 119 insertions(+) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 9d45e4a76..715eb670e 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3153,6 +3153,123 @@

[libvirt] [PATCH v2 14/15] vbox: Process empty removable disks in dumpxml

2017-10-24 Thread Dawid Zamirski
Previously any removable storage device without media attached was omitted from domain XML dump. They're still (rightfully) omitted in snapshot XMl dump but need to be accounted properly to for the device names to stay in 'sync' between domain and snapshot XML dumps. --- src/vbox/vbox_common.c |

[libvirt] [PATCH v2 12/15] vbox: Correctly generate drive name in dumpxml

2017-10-24 Thread Dawid Zamirski
If a VBOX VM has e.g. a SATA and SCSI disk attached, the XML generated by dumpxml used to produce "sda" for both of those disks. This is an invalid domain XML as libvirt does not allow duplicate device names. To address this, keep the running total of disks that will use "sd" prefix for device

[libvirt] [PATCH v2 06/15] vbox: Errors in vboxAttachDrives are now critical

2017-10-24 Thread Dawid Zamirski
Previously, if one tried to define a VBOX VM and the API failed to perform the requested actions for some reason, it would just log the error and move on to process remaining disk definitions. This is not desired as it could result in incorrectly defined VM without the caller even knowing about

[libvirt] [PATCH v2 00/15] vbox: Improve handling of storage devices

2017-10-24 Thread Dawid Zamirski
From: Dawid Zamirski v1: https://www.redhat.com/archives/libvir-list/2017-October/msg00381.html Changes since v1: * split out the original patches into smaller ones, with each bugfix or cleanup task is in its own isolated and compilable patch * make sure switch statements

[libvirt] [PATCH v2 10/15] vbox: Process element in domain XML

2017-10-24 Thread Dawid Zamirski
This patch enables the VBOX driver to process the element in domain XML through which one can now customize the controller model. Since VirtualBox has two distinct SAS and SCSI they do not "map" directly to libvirt XML, he VBOX driver uses to create SAS controller in VBOX VM. Additionally once

[libvirt] [PATCH v2 15/15] vbox: Generate disk address element in dumpxml

2017-10-24 Thread Dawid Zamirski
This patch adds element to each device since device names alone won't adequately reflect the storage device layout in the VM. With this patch, the ouput produced by dumpxml will faithfully reproduce the storage layout of the VM if used with define. --- src/vbox/vbox_common.c | 79

[libvirt] [PATCH v2 01/15] vbox: Update ATTRIBUTE_UNUSED usage

2017-10-24 Thread Dawid Zamirski
Since the removal of VBOX <= 3x, the function arguments are actually used so they should not be marked with ATTRIBUTE_UNUSED anymore. --- src/vbox/vbox_tmpl.c | 49 +++-- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git

[libvirt] [PATCH v2 09/15] domain: Allow 'model' attribute for ide controller

2017-10-24 Thread Dawid Zamirski
The optional values are 'piix3', 'piix4' or 'ich6'. Those will be needed to allow setting IDE controller model in VirtualBox driver. --- docs/formatdomain.html.in | 4 docs/schemas/domaincommon.rng | 18 -- src/conf/domain_conf.c| 9 +

[libvirt] [PATCH v2 07/15] vbox: Support empty removable drives.

2017-10-24 Thread Dawid Zamirski
Original code was checking for non empty disk source before proceeding to actually attach disk device to VM. This prevented from creating empty removable devices like DVD or floppy. Therefore, this patch re-organizes the loop work-flow to allow such configurations as well as makes the code follow

[libvirt] [PATCH v2 08/15] vbox: Add more IStorageController API mappings

2017-10-24 Thread Dawid Zamirski
This patch exposes additional methods of the native VBOX API to the libvirt 'unified' vbox API to deal with IStorageController. The exposed methods are: * IStorageController->GetStorageControllerType() * IStorageController->SetStorageControllerType() * IMachine->GetStorageControllers() ---

[libvirt] [PATCH v2 05/15] vbox: Cleanup vboxAttachDrives implementation

2017-10-24 Thread Dawid Zamirski
This commit primes vboxAttachDrives for further changes so when they are made, the diff is less noisy: * move variable declarations to the top of the function * add disk variable to replace all the def->disks[i] instances * add cleanup at the end of the loop body, so it's all in one place

[libvirt] [PATCH v2 03/15] vbox: Cleanup partially-defined VM on failure

2017-10-24 Thread Dawid Zamirski
Since the VBOX API requires to register an initial VM before proceeding to attach any remaining devices to it, any failure to attach such devices should result in automatic cleanup of the initially registered VM so that the state of VBOX registry remains clean without any leftover "aborted" VMs in

[libvirt] [PATCH v2 02/15] vbox: Close media when undefining domains

2017-10-24 Thread Dawid Zamirski
When registering a VM we call OpenMedium on each disk image which adds it to vbox's global media registry. Therefore, we should make sure to call Close when unregistering VM so we cleanup the media registry entries after ourselves - this does not remove disk image files. This follows the behaviour

[libvirt] [PATCH v2 04/15] vbox: vboxAttachDrives now relies on address info

2017-10-24 Thread Dawid Zamirski
Previously, the driver was computing VBOX's devicePort/deviceSlot values based on device name and max port/slot values. While this worked, it completely ignored values. Additionally, libvirt's built-in virDomainDiskDefAssignAddress already does a good job setting default values on

[libvirt] [[RFC] 2/8] QEMU Event handling: Introduce async event helpers in qemu_event.[ch]

2017-10-24 Thread Prerna Saxena
These contain basic functions for setting up event lists (global as well as per-VM). Also include methods for enqueuing and dequeuing events. Per-event metadata is also encoded herewith. Signed-off-by: Prerna Saxena --- src/Makefile.am | 1 + src/qemu/qemu_event.c

[libvirt] [[RFC] 4/8] Events: Allow monitor to "enqueue" events to a queue. Also introduce a framework of handlers for each event type, that can be called when the handler is running an event.

2017-10-24 Thread Prerna Saxena
Signed-off-by: Prerna Saxena --- src/qemu/qemu_event.c| 11 + src/qemu/qemu_event.h| 8 + src/qemu/qemu_monitor.c | 592 +++- src/qemu/qemu_monitor.h | 80 +++-- src/qemu/qemu_monitor_json.c | 291 ++--

[libvirt] [[RFC] 7/8] Fold back the 2-stage event implementation for a few events : Watchdog, Monitor EOF, Serial changed, Guest panic, Nic RX filter changed .. into single level.

2017-10-24 Thread Prerna Saxena
Also, the enqueuing of a new event now triggers virEventWorkerScanQueue() Signed-off-by: Prerna Saxena --- src/qemu/qemu_driver.c | 61 ++-- src/qemu/qemu_process.c | 121 +++- 2 files changed, 29

[libvirt] [[RFC] 5/8] Events: Plumb event handling calls before a domain's APIs complete.

2017-10-24 Thread Prerna Saxena
Signed-off-by: Prerna Saxena --- src/qemu/qemu_driver.c | 131 +++-- 1 file changed, 128 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a005d0..b249347 100644 ---

[libvirt] [[RFC] 8/8] Initialize the per-VM event queues in context of domain init.

2017-10-24 Thread Prerna Saxena
Signed-off-by: Prerna Saxena --- src/qemu/qemu_driver.c | 20 src/qemu/qemu_event.c | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 881f253..e4b6d06 100644 --- a/src/qemu/qemu_driver.c +++

[libvirt] [[RFC] 6/8] Code refactor: Move helper functions of doCoreDump*, syncNicRxFilter*, and qemuOpenFile* to qemu_process.[ch]

2017-10-24 Thread Prerna Saxena
Signed-off-by: Prerna Saxena --- src/qemu/qemu_driver.c | 1161 --- src/qemu/qemu_process.c | 1133 + src/qemu/qemu_process.h | 86 3 files changed, 1219 insertions(+), 1161

[libvirt] [[RFC] 1/8] Introduce virObjectTrylock()

2017-10-24 Thread Prerna Saxena
This is a wrapper function that: (1) Attempts to take a lock on the object. (2) gracefully returns if the object is already locked. Signed-off-by: Prerna Saxena --- src/libvirt_private.syms | 1 + src/util/virobject.c | 26 ++

[libvirt] [[RFC] 3/8] Setup global and per-VM event queues. Also initialize per-VM queues when libvirt reconnects to an existing VM.

2017-10-24 Thread Prerna Saxena
Signed-off-by: Prerna Saxena --- src/conf/domain_conf.h | 3 + src/qemu/qemu_conf.h| 4 + src/qemu/qemu_driver.c | 9 ++ src/qemu/qemu_event.c | 229 src/qemu/qemu_event.h | 1 - src/qemu/qemu_process.c |

[libvirt] [[RFC] 0/8] Implement async QEMU event handling in libvirtd.

2017-10-24 Thread Prerna Saxena
As noted in https://www.redhat.com/archives/libvir-list/2017-May/msg00016.html libvirt-QEMU driver handles all async events from the main loop. Each event handling needs the per-VM lock to make forward progress. In the case where an async event is received for the same VM which has an RPC

[libvirt] [PATCH] virt-aa-helper: grant locking permission on -f

2017-10-24 Thread Christian Ehrhardt
Hot-adding disks does not parse the full XML to generate apparmor rules. Instead it uses -f to append a generic rule for that file path. 580cdaa7: "virt-aa-helper: locking disk files for qemu 2.10" implemented the qemu 2.10 requirement to allow locking on disks images that are part of the domain

[libvirt] [PATCH v2 3/4] qemu: Use predictable file names for memory-backend-file

2017-10-24 Thread Michal Privoznik
In some cases management application needs to allocate memory for qemu upfront and then just let qemu use that. Since we don't want to expose path for memory-backend-file anywhere in the domain XML, we can generate predictable paths. In this case:

[libvirt] [PATCH v2 2/4] qemu: Move memPath generation from memoryBackingDir to a separate function

2017-10-24 Thread Michal Privoznik
In near future we will need more than just a plain VIR_STRDUP(). Better implement that in a separate function and in qemuBuildMemoryBackendStr() which is complicated enough already. Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_conf.c

[libvirt] [PATCH v2 1/4] conf: s/virDomainObjGetShortName/virDomainDefGetShortName/

2017-10-24 Thread Michal Privoznik
This function works over domain definition and not domain object. Its name is thus misleading. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 2 +- src/qemu/qemu_conf.c | 2 +-

[libvirt] [PATCH v2 4/4] news: Document predictable file names for memory-backend-file

2017-10-24 Thread Michal Privoznik
Signed-off-by: Michal Privoznik --- docs/news.xml | 11 +++ 1 file changed, 11 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 989b82aa5..29eaacb9a 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -51,6 +51,17 @@ + +

[libvirt] [PATCH v2 0/4] Predictable file names for memory-backend-file

2017-10-24 Thread Michal Privoznik
v2 of: https://www.redhat.com/archives/libvir-list/2017-October/msg01063.html Patches are to be found here too: https://github.com/zippy2/libvirt/tree/qemu_mem_path_v3 diff to v1: -Dropped qemu.conf config knob -s/rmdir/virFileDeleteTree/ in qemuProcessBuildDestroyMemoryPathsImpl() because

[libvirt] [PATCH v3 2/2] virtlogd: add missing netserver refcount increment on reload

2017-10-24 Thread Nikolay Shirokovskiy
After virNetDaemonAddServerPostExec call in virtlogd we should have netserver refcount set to 2. One goes to netdaemon servers hashtable and one goes to virtlogd own reference to netserver. Let's add missing increment in virNetDaemonAddServerPostExec itself while holding daemon lock. We also have

[libvirt] [PATCH v3 1/2] libvirtd: fix crash on termination

2017-10-24 Thread Nikolay Shirokovskiy
The problem is incorrect order of qemu driver shutdown and shutdown of netserver threads that serve client requests (thru qemu driver particularly). Net server threads are shutdowned upon dispose which is triggered by last daemon object unref at the end of main function. At the same time qemu

[libvirt] [PATCH v3 0/2] daemon: fix termination/reload issues

2017-10-24 Thread Nikolay Shirokovskiy
v1: https://www.redhat.com/archives/libvir-list/2017-September/msg01006.html Changes from v2: Fix syntax check issues. Changes from v1: 1. Patches that fixes qemu driver termination are moved out of this series 2. New version of [1] now fixes issue in a way that suggested by reviewer 3.

Re: [libvirt] [PATCH v2 0/2] daemon: fix termination/reload issues

2017-10-24 Thread Nikolay Shirokovskiy
Please, ignore. Need to resend after syntax check issues fixed. On 24.10.2017 12:52, Nikolay Shirokovskiy wrote: > v1: https://www.redhat.com/archives/libvir-list/2017-September/msg01006.html > > Changes from v1: > > 1. Patches that fixes qemu driver termination are moved out of this series >

[libvirt] [PATCH v2 1/2] libvirtd: fix crash on termination

2017-10-24 Thread Nikolay Shirokovskiy
The problem is incorrect order of qemu driver shutdown and shutdown of netserver threads that serve client requests (thru qemu driver particularly). Net server threads are shutdowned upon dispose which is triggered by last daemon object unref at the end of main function. At the same time qemu

[libvirt] [PATCH v2 0/2] daemon: fix termination/reload issues

2017-10-24 Thread Nikolay Shirokovskiy
v1: https://www.redhat.com/archives/libvir-list/2017-September/msg01006.html Changes from v1: 1. Patches that fixes qemu driver termination are moved out of this series 2. New version of [1] now fixes issue in a way that suggested by reviewer 3. [2] fixes another issue that was discovered in the

[libvirt] [PATCH v2 2/2] virtlogd: add missing netserver refcount increment on reload

2017-10-24 Thread Nikolay Shirokovskiy
After virNetDaemonAddServerPostExec call in virtlogd we should have netserver refcount set to 2. One goes to netdaemon servers hashtable and one goes to virtlogd own reference to netserver. Let's add missing increment in virNetDaemonAddServerPostExec itself while holding daemon lock. We also have

Re: [libvirt] [PATCH] spec: Restart libvirtd in posttrans

2017-10-24 Thread Pavel Hrdina
On Mon, Oct 23, 2017 at 06:07:49PM +0200, Pavel Hrdina wrote: > On Mon, Oct 23, 2017 at 04:00:57PM +0200, Jiri Denemark wrote: > > When upgrading libvirt packages, there's no strict ordering for the > > installation or removal of the individual libvirt sub packages. Thus > > libvirt-daemon may be

Re: [libvirt] [PATCH] virsh: domain: Fix option handling in domxml-to-native

2017-10-24 Thread Pavel Hrdina
On Tue, Oct 24, 2017 at 09:51:31AM +0200, Peter Krempa wrote: > Commit fdeac7a05fdf85458d72e89efcfa0f444525aaad tried to fix the output > of 'virsh --help domxml-to-native' by switching types around. One of the > changes broke the option parser. VSH_OT_ARGV should be used only for > variable

Re: [libvirt] [PATCH] qemu: Reset hasManagedSave after removing a corrupted image

2017-10-24 Thread Peter Krempa
On Tue, Oct 24, 2017 at 10:39:53 +0200, Jiri Denemark wrote: > When starting a domain with managed save image, we try to restore it > first. If the image is corrupted, we silently unlink it and just > normally start the domain. At this point the domain has no managed save > image, yet we did not

Re: [libvirt] [PATCH] iohelper: use saferead if later write with O_DIRECT

2017-10-24 Thread Jiri Denemark
On Thu, Sep 28, 2017 at 10:06:47 +0300, Nikolay Shirokovskiy wrote: > One of the usecases of iohelper is to read from pipe and write > to file with O_DIRECT. As we read from pipe we can have partial > read and then we fail to write this data because output file > is open with O_DIRECT and buffer

[libvirt] [PATCH] qemu: Reset hasManagedSave after removing a corrupted image

2017-10-24 Thread Jiri Denemark
When starting a domain with managed save image, we try to restore it first. If the image is corrupted, we silently unlink it and just normally start the domain. At this point the domain has no managed save image, yet we did not reset the hasManagedSave flag.

Re: [libvirt] [PATCH v1 3/5] qemu.conf: Introduce memory_predictable_file_names

2017-10-24 Thread Daniel P. Berrange
On Mon, Oct 23, 2017 at 07:10:04PM +0200, Michal Privoznik wrote: > On 10/23/2017 06:47 PM, Daniel P. Berrange wrote: > > On Mon, Oct 23, 2017 at 05:43:16PM +0200, Michal Privoznik wrote: > >> In some cases management application needs to allocate memory for > >> qemu upfront and then just let

[libvirt] [PATCH] virsh: domain: Fix option handling in domxml-to-native

2017-10-24 Thread Peter Krempa
Commit fdeac7a05fdf85458d72e89efcfa0f444525aaad tried to fix the output of 'virsh --help domxml-to-native' by switching types around. One of the changes broke the option parser. VSH_OT_ARGV should be used only for variable argument count, not to make the help generator look pretty. The correct

Re: [libvirt] [PATCH] iohelper: use saferead if later write with O_DIRECT

2017-10-24 Thread Nikolay Shirokovskiy
ping On 28.09.2017 10:06, Nikolay Shirokovskiy wrote: > One of the usecases of iohelper is to read from pipe and write > to file with O_DIRECT. As we read from pipe we can have partial > read and then we fail to write this data because output file > is open with O_DIRECT and buffer size is not

Re: [libvirt] libvirt not wanting to read back its own interface XML

2017-10-24 Thread Guido Günther
Hi Marc, On Sun, Oct 22, 2017 at 10:37:44AM +0200, Marc Haber wrote: > Hi Guido, > > I didn't mean to accuse Debian of doing a bad job with netcf. I didn't read it like that either. > > On Sun, Oct 22, 2017 at 09:26:31AM +0200, Guido Günther wrote: > > On Thu, Oct 19, 2017 at 02:41:31PM +0200,