[libvirt] [libvirt-glib v2 0/9] gconfig: Add hostdev support
by Christophe Fergeau
Hey,
While reviewing Zeeshan's libvirt-gconfig hostdev series, I fixed up a few
things, and added a few additional helpers/getters in order to simplify the
code/make the test case more complete.
This series contains this new code. The changes I made to Zeeshan's initial
patches are in separate fixup! commits to make reviewing them easier (for you Zeeshan ;).
I expect these to be squashed in the main commits before being pushed.
Zeeshan's commits are unchanged from v1.
Christophe
8 years, 7 months
Re: [libvirt] dist-git build problem on epel-6-x86_64 chroot
by Jean-Marc LIGER
Le 19/02/2016 11:40, Miroslav Suchý a écrit :
> Dne 19.1.2016 v 17:01 Jean-Marc LIGER napsal(a):
>> Hy,
>>
>> I'm facing the problem below on epel-6-x86_64 chroot for both from URL and upload SRPM :
>>
>> [2016-01-19 15:16:26,790][ INFO][PID:3241] Setting up builder: 172.25.94.167
>> [2016-01-19 15:16:27,991][ INFO][PID:3241] marking build dir with build_id,
>> [2016-01-19 15:16:27,992][ INFO][PID:3241] Start build: BuildJob<id: 154509, owner: jmliger, project: virt6-upstream,
>> git branch: el6, git_hash: acef5efd6153aa8f9ea760f468333e65c9b46a4e, status: 3 >
>> [2016-01-19 15:16:27,993][ INFO][PID:3241] putting into minimal buildroot of epel-6-x86_64
>> [2016-01-19 15:16:28,902][ INFO][PID:3241] Cloning Dist Git repo jmliger/virt6-upstream/libvirt, branch
>> acef5efd6153aa8f9ea760f468333e65c9b46a4e, hash el6
>> [2016-01-19 15:16:30,906][ ERROR][PID:3241] Failed to obtain srpm from dist-git
>> Traceback (most recent call last):
>> File "/usr/share/copr/backend/mockremote/builder.py", line 209, in download_job_pkg_to_builder
>> self.remote_pkg_path = list(results["contacted"].values())[0][u"stdout"].split("Wrote: ")[1]
>> IndexError: list index out of range
>> [2016-01-19 15:16:30,911][ ERROR][PID:3241] builder.build error building pkg `libvirt`: BuildError: Failed to obtain
>> srpm from dist-git: ansible results {'dark': {}, 'contacted': {'172.25.94.167': {'cmd': 'rm -rf /tmp/build_package_repo
>> && mkdir /tmp/build_package_repo && cd /tmp/build_package_repo && git clone
>> http://copr-dist-git.fedorainfracloud.org/git/jmliger/virt6-upstream/libv... && cd libvirt && git checkout
>> acef5efd6153aa8f9ea760f468333e65c9b46a4e && fedpkg-copr --dist el6 srpm', 'end': '2016-01-19 15:16:30.308282', 'stdout':
>> 'Downloading libvirt-1.3.1.tar.gz\n\r
>> 0.0%\r
>> 100.0%\r######################################################################## 100.0%', 'changed': True, 'start':
>> '2016-01-19 15:16:28.758321', 'delta': '0:00:01.549961', 'stderr': "Cloning into 'libvirt'...\nNote: checking out
>> 'acef5efd6153aa8f9ea760f468333e65c9b46a4e'.\n\nYou are in 'detached HEAD' state. You can look around, make
>> experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any
>> branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo
>> so (now or later) by using -b with the checkout command again. Example:\n\n git checkout -b <new-branch-name>\n\nHEAD
>> is now at acef5ef... import_srpm\nerror: line 1800: Trigger fired by the same package is already defined in spec file:
>> %post daemon-config-network\n\nerror: query of specfile /tmp/build_package_repo/libvirt/libvirt.spec failed, can't
>> parse\n\nCould not execute srpm: Could not get n-v-r-e from '\\n\\n'", 'rc': 1, 'invocation': {'module_name': 'shell',
>> 'module_complex_args': {}, 'module_args': u'rm -rf /tmp/build_package_repo && mkdir /tmp/build_package_repo && cd
>> /tmp/build_package_repo && git clone http://copr-dist-git.fedorainfracloud.org/git/jmliger/virt6-upstream/libv... &&
>> cd libvirt && git checkout acef5efd6153aa8f9ea760f468333e65c9b46a4e && fedpkg-copr --dist el6 srpm'}, 'warnings':
>> ['Consider using file module with state=absent rather than running rm']}}}
>> [2016-01-19 15:16:31,759][ INFO][PID:3241] End Build: BuildJob<id: 154509, owner: jmliger, project: virt6-upstream, git
>> branch: el6, git_hash: acef5efd6153aa8f9ea760f468333e65c9b46a4e, status: 3 >
>>
>> https://copr.fedoraproject.org/coprs/jmliger/virt6-upstream/builds/
>>
>> Regards,
>> Jean-Marc LIGER
>>
>>
>> _______________________________________________
>> copr-devel mailing list
>> copr-devel(a)lists.fedorahosted.org
>> https://lists.fedorahosted.org/admin/lists/copr-devel@lists.fedorahosted.org
> It is some problem with your spec file.
> You can reproduce it by installing fedpkg-copr from our Copr project and
> git clone http://copr-dist-git.fedorainfracloud.org/git/jmliger/virt6-upstream/libv...
> cd libvirt
> git checkout acef5efd6153aa8f9ea760f468333e65c9b46a4e
> fedpkg-copr -vvv --dist el6 srpm
>
> Which will fails on:
>
> rpm --define '_sourcedir /tmp/libvirt' --define '_specdir /tmp/libvirt' --define '_builddir /tmp/libvirt' --define
> '_srcrpmdir /tmp/libvirt' --define '_rpmdir /tmp/libvirt' --define 'dist .el6' --define 'rhel 6' --eval '%undefine
> fedora' --define 'el6 1' --eval '%undefine fc23' -q --qf "%{NAME} %{EPOCH} %{VERSION} %{RELEASE}??" --specfile
> /tmp/libvirt/libvirt.spec
>
> error: line 1800: Trigger fired by the same package is already defined in spec file: %post daemon-config-network
> error: query of specfile /tmp/libvirt/libvirt.spec failed, can't parse
>
> And your spec file is so complex that I have no idea why it is failing. You may ask on RPM mailing list.
>
Thanks for your reply, I'm addressing this problem to the libvirt list.
8 years, 7 months
[libvirt] [PATCH 0/2] RFC: qemu: aarch64 virtio-pci work
by Cole Robinson
These patches apply on top of the series I just posted:
[PATCH 0/9] tests: qemu: unconditionally enable QEMU_CAPS_DEVICE
https://www.redhat.com/archives/libvir-list/2016-January/msg01233.html
These specific changers were discussed here:
https://www.redhat.com/archives/libvir-list/2015-December/msg00217.html
We need a way for apps to tell libvirt 'use virtio-pci not virtio-mmio'
for aarch64 -M virt. We can't really make use this by default yet since
most OS don't actually support it. So we decided the best course of
interaction is to allow users to pass a manual pci controller, and libvirt
will interpret that to mean it's okay to use virtio-pci.
Patch #1 undoes the current behavior of unconditionally adding a q35 style
PCIe controller setup for mach-virt that supports it. In the future we
will probably re-enable something like this, but maybe not for a year or
so until the bits proliferate to distros.
Patch #2 tries to implement the manual pci controller bit. Unfortunately
it's not that easy get the ideal XML to work, so this isn't ready for
committing. See the commit message for more details
Cole Robinson (2):
qemu: aarch64: Don't add PCIe controller by default
HACK: qemu: aarch64: Use virtio-pci if user specifies PCI controller
src/qemu/qemu_command.c | 34 ++++++++----
src/qemu/qemu_domain.c | 4 --
...l2argv-aarch64-pci-manual-nocontroller-fail.xml | 43 ++++++++++++++++
.../qemuxml2argv-aarch64-virtio-pci-default.args | 2 -
...l2argv-aarch64-virtio-pci-manual-addresses.args | 2 -
...ml2argv-aarch64-virtio-pci-manual-addresses.xml | 1 +
...2argv-aarch64-virtio-pci-manual-controller.args | 36 +++++++++++++
...l2argv-aarch64-virtio-pci-manual-controller.xml | 50 ++++++++++++++++++
tests/qemuxml2argvtest.c | 22 ++++++--
.../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 10 ----
...2xmlout-aarch64-virtio-pci-manual-addresses.xml | 11 +---
...xmlout-aarch64-virtio-pci-manual-controller.xml | 60 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 6 +++
13 files changed, 239 insertions(+), 42 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-pci-manual-nocontroller-fail.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-controller.xml
--
2.5.0
8 years, 7 months
[libvirt] [PATCH v2 0/8] Use virtlogd for chardevs & support logging
by Daniel P. Berrange
This series of patches does two things
* Converts the type=file chardev over to use virtlogd
(assuming use of virtlogd is enabled in qemu.conf)
* Adds a <log file="..."/> element to all chardev
sources, allowing data to be captured to a logfile
Both of these are important features wanted by openstack.
The first thing fixes a long standing security issue that
a guest OS can trivially exhuast host disk space by outputing
lots of data to its serial port.
The second thing allows OpenStack to record boot up
messages for a guest's serial console, while still
allowing interactive serial console ussage. ie the
serial port will be configured with type=tcp, and
the new <log> element used to record the data.
Both these thing required changes in QEMU, which have
been merged for the forthcoming QEMU 2.6 release.
Changed in v2:
* Split patch 4 up into 4 separate patches
* Fix memory leaks
* Use common function for building log manager cli args
* Add missing XML docs
Daniel P. Berrange (8):
logging: allow inode/offset params to be NULL
conf: allow use of a logfile with chardev backends
qemu: add support for logging chardev output to a file
qemu: don't append -chardev arg until after value is formatted
qemu: move functions for handling FD passing
logging: support truncation of logfiles when opening
qemu: use virtlogd for character device log files
qemu: support use of virtlogd with file based chardevs
docs/formatdomain.html.in | 14 +
docs/schemas/domaincommon.rng | 12 +
src/conf/domain_conf.c | 30 +++
src/conf/domain_conf.h | 2 +
src/logging/log_daemon_dispatch.c | 3 +-
src/logging/log_handler.c | 6 +-
src/logging/log_handler.h | 2 +-
src/logging/log_manager.c | 6 +-
src/logging/log_manager.h | 2 +
src/logging/log_protocol.x | 4 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 282 ++++++++++++++-------
src/qemu/qemu_command.h | 9 +-
src/qemu/qemu_domain.c | 6 +
src/qemu/qemu_domain.h | 3 +
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_process.c | 4 +-
.../qemuxml2argv-serial-file-log.args | 25 ++
.../qemuxml2argv-serial-file-log.xml | 39 +++
tests/qemuxml2argvtest.c | 4 +-
21 files changed, 353 insertions(+), 105 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-log.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-log.xml
--
2.5.0
8 years, 7 months
[libvirt] [PATCH] libxl: small fix in parsing network
by Chunyan Liu
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/libxl/libxl_conf.c | 2 +-
src/libxl/libxl_domain.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 5133299..48b8826 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1471,7 +1471,7 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
VIR_SHRINK_N(x_nics, nnics, nnics - nvnics);
d_config->nics = x_nics;
- d_config->num_nics = nnics;
+ d_config->num_nics = nvnics;
return 0;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 632acfd..50f7eed 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -315,7 +315,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainHostdevSubsysPCIPtr pcisrc;
if (dev->type == VIR_DOMAIN_DEVICE_NET)
- hostdev = &(dev->data.net)->data.hostdev.def;
+ hostdev = &dev->data.net->data.hostdev.def;
else
hostdev = dev->data.hostdev;
pcisrc = &hostdev->source.subsys.u.pci;
--
2.1.4
8 years, 7 months
[libvirt] [PATCH 0/9] vcpu info refactors - part 3b
by Peter Krempa
Yet another continuation of the saga. In this episode we add pinning for
inactive cpus.
Peter Krempa (9):
virsh: vcpupin: Ask for pinning info for all vCPUs
conf: Extract code filling data for virDomainGetVcpuPinInfo
qemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo
conf: introduce parser feature flags
conf: refactor checking for unsupported memory devices
conf: extract ignoring of inactive vcpu pinning information
qemu: add support for offline vcpupin
qemu: vcpupin: Extract live vcpupin setting into a separate function
qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags
src/bhyve/bhyve_domain.c | 9 +-
src/conf/domain_conf.c | 157 +++++++++++++++++++++++++++---
src/conf/domain_conf.h | 20 +++-
src/libvirt_private.syms | 3 +-
src/libxl/libxl_domain.c | 7 --
src/libxl/libxl_driver.c | 38 +-------
src/lxc/lxc_domain.c | 8 --
src/openvz/openvz_driver.c | 7 --
src/phyp/phyp_driver.c | 6 +-
src/qemu/qemu_domain.c | 2 +
src/qemu/qemu_driver.c | 234 +++++++++++++++++++--------------------------
src/test/test_driver.c | 38 +-------
src/uml/uml_driver.c | 9 +-
src/vbox/vbox_common.c | 6 +-
src/vmware/vmware_driver.c | 6 +-
src/vmx/vmx.c | 8 +-
src/vz/vz_driver.c | 6 +-
src/xen/xen_driver.c | 7 --
src/xenapi/xenapi_driver.c | 7 --
tools/virsh-domain.c | 3 +-
20 files changed, 279 insertions(+), 302 deletions(-)
--
2.6.2
8 years, 7 months
[libvirt] [PATCH] ruby-libvirt: Don't crash in leases_wrap() by passing NULLs to rb_str_new2()
by Dan Williams
Not all lease values are mandatory, and when they aren't supplied
by the libvirt driver they get set to NULL. That makes
rb_str_new2() bail out.
Signed-off-by: Dan Williams <dcbw(a)redhat.com>
---
For example using the qemu driver we don't get 'iaid', and that
makes ruby unhappy:
[{"iface"=>"virbr1", "expirytime"=>1452189569, "type"=>0, "mac"=>"52:54:00:05:2b:6f",
"ipaddr"=>"192.168.121.49", "prefix"=>24, "hostname"=>"openshiftdev",
"clientid"=>"ff:00:05:2b:6f:00:01:00:01:1e:21:55:ed:52:54:00:05:2b:6f"}]
ext/libvirt/network.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/ext/libvirt/network.c b/ext/libvirt/network.c
index 7c77d73..c250d7d 100644
--- a/ext/libvirt/network.c
+++ b/ext/libvirt/network.c
@@ -269,14 +269,20 @@ static VALUE leases_wrap(VALUE arg)
rb_hash_aset(hash, rb_str_new2("expirytime"),
LL2NUM(lease->expirytime));
rb_hash_aset(hash, rb_str_new2("type"), INT2NUM(lease->type));
- rb_hash_aset(hash, rb_str_new2("mac"), rb_str_new2(lease->mac));
- rb_hash_aset(hash, rb_str_new2("iaid"), rb_str_new2(lease->iaid));
+ if (lease->mac)
+ rb_hash_aset(hash, rb_str_new2("mac"), rb_str_new2(lease->mac));
+ if (lease->iaid)
+ rb_hash_aset(hash, rb_str_new2("iaid"), rb_str_new2(lease->iaid));
rb_hash_aset(hash, rb_str_new2("ipaddr"), rb_str_new2(lease->ipaddr));
rb_hash_aset(hash, rb_str_new2("prefix"), UINT2NUM(lease->prefix));
- rb_hash_aset(hash, rb_str_new2("hostname"),
- rb_str_new2(lease->hostname));
- rb_hash_aset(hash, rb_str_new2("clientid"),
- rb_str_new2(lease->clientid));
+ if (lease->hostname) {
+ rb_hash_aset(hash, rb_str_new2("hostname"),
+ rb_str_new2(lease->hostname));
+ }
+ if (lease->clientid) {
+ rb_hash_aset(hash, rb_str_new2("clientid"),
+ rb_str_new2(lease->clientid));
+ }
rb_ary_store(result, i, hash);
}
--
2.4.3
8 years, 7 months
[libvirt] [PATCH 00/25] Final pile of qemu_command.c changes
by John Ferlan
Finishing the adventure - certainly qemuBuildCommandLine looks much
cleaner now and is much shorter (~2100 lines down to ~250 lines).
The downside is plowing though the changes and the reviews.
John Ferlan (25):
qemu: Introduce qemuBuildClockCommandLine
qemu: Introduce qemuBuildPMCommandLine
qemu: Introduce qemuBuildBootCommandLine
qemu: Introduce qemuBuildGlobalControllerCommandLine
qemu: Introduce qemuBuildControllerDevCommandLine
qemu: Introduce qemuBuildHubCommandLine
qemu: Introduce qemuBuildDiskDriveCommandLine
qemu: Introduce qemuBuildFSDevCommandLine
qemu: Introduce qemuBuildNetCommandLine
qemu: Introduce qemuBuildSmartcardCommandLine
qemu: Introduce qemuBuildSerialCommandLine
qemu: Introduce qemuBuildParallelsCommandLine
qemu: Introduce qemuBuildChannelsCommandLine
qemu: Introduce qemuBuildConsoleCommandLine
qemu: Modify qemuBuildTPMCommandLine
qemu: Introduce qemuBuildInputCommandLine
qemu: Introduce qemuBuildVideoCommandLine
qemu: Introduce qemuBuildSoundCommandLine
qemu: Introduce qemuBuildWatchdogCommandLine
qemu: Introduce qemuBuildRedirdevCommandLine
qemu: Introduce qemuBuildHostdevCommandLine
qemu: Introduce qemuBuildMemballoonCommandLine
qemu: Introduce qemuBuildRNGCommandLine
qemu: Introduce qemuBuildNVRAMCommandLine
qemu: Introduce qemuBuildPanicCommandLine
src/conf/domain_conf.c | 14 +-
src/conf/domain_conf.h | 8 +-
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_capabilities.h | 2 +-
src/qemu/qemu_command.c | 7703 +++++++++++++++++++++-------------------
src/qemu/qemu_command.h | 46 +-
src/qemu/qemu_domain_address.c | 2 +-
src/qemu/qemu_domain_address.h | 2 +-
8 files changed, 4073 insertions(+), 3706 deletions(-)
--
2.5.0
8 years, 7 months
[libvirt] [PATCH] Use correct pci addresses during interface-detach[v2]
by Nitesh Konkar
The virsh attach virsh detach interface command fails when both live and config
are set and when the interface gets attached to different pci slots
on live and config xml respectively.
When we attach an interface with both --live and --config,
the first time they get the same PCI slots, but the second time
onwards it differs and hence the virsh detach-interface --live
--config command fails. This patch makes sure that when both
--live --config are set , qemuDomainDetachDeviceFlags is called
twice, once with config xml and once with live xml.
Steps to see the issue:
virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config
virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config
virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config
virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config
Signed-off-by:nitkon12@linux.vnet.ibm.com
---
tools/virsh-domain.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 62acecb..43c8436 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10815,7 +10815,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
char buf[64];
int diff_mac;
size_t i;
- int ret;
+ int ret, flag_live_config_both = 0;
bool functionReturn = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
@@ -10830,7 +10830,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (config || persistent)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
- if (live)
+ if (!(config || persistent) && live) // Only Live
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
@@ -10851,6 +10851,8 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
else
doc = virDomainGetXMLDesc(dom, 0);
+ forlivexml:
+
if (!doc)
goto cleanup;
@@ -10921,6 +10923,14 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach interface"));
} else {
+ if ((config || persistent) && live && flag_live_config_both == 0) {//executed only when live config both in cmd.
+ doc = virDomainGetXMLDesc(dom, 0);
+ flag_live_config_both=1; //Need to execute this code only once
+ flags |= VIR_DOMAIN_AFFECT_LIVE; //set live flag
+ flags &= (~VIR_DOMAIN_AFFECT_CONFIG ); // need to unset config flag as config xml detach is already done.
+ mac=NULL;
+ goto forlivexml;
+ }
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
functionReturn = true;
}
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] qemu: Support to detach redirdev device
by Osier Yang
Attaching redirdev device has been supported for a while, but detaching
is not never implemented.
Simple procedure to test:
% lsusb
Bus 001 Device 014: ID 0781:5567 SanDisk Corp. Cruzer Blade
% usbredirserver -p 4000 0781:5567
% virsh attach-device test usb.xml
% cat usb.xml
<redirdev bus='usb' type='tcp'>
<source mode='connect' host='192.168.84.6' service='4000'/>
</redirdev>
% virsh detach-device test usb.xml
% virsh qemu-monitor-command test --pretty '{"execute": "query-chardev"}' | grep 4000
On success, the chardev should not seen in output of above command.
---
src/conf/domain_conf.c | 67 +++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++
src/libvirt_private.syms | 3 ++
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_hotplug.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_hotplug.h | 3 ++
6 files changed, 176 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3b15cb4..d304232 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13825,6 +13825,73 @@ virDomainMemoryRemove(virDomainDefPtr def,
return ret;
}
+ssize_t
+virDomainRedirdevFind(virDomainDefPtr def,
+ virDomainRedirdevDefPtr redirdev)
+{
+ size_t i;
+
+ for (i = 0; i < def->nredirdevs; i++) {
+ virDomainRedirdevDefPtr tmp = def->redirdevs[i];
+
+ if (redirdev->bus != tmp->bus)
+ continue;
+
+ virDomainChrSourceDef source_chr = redirdev->source.chr;
+ virDomainChrSourceDef tmp_chr = tmp->source.chr;
+
+ if (source_chr.type != tmp_chr.type)
+ continue;
+
+ switch (source_chr.type) {
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ if (STRNEQ_NULLABLE(source_chr.data.tcp.host,
+ tmp_chr.data.tcp.host))
+ continue;
+ if (STRNEQ_NULLABLE(source_chr.data.tcp.service,
+ tmp_chr.data.tcp.service))
+ continue;
+ if (source_chr.data.tcp.listen != tmp_chr.data.tcp.listen)
+ continue;
+ if (source_chr.data.tcp.protocol != tmp_chr.data.tcp.protocol)
+ continue;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+ if (source_chr.data.spicevmc != tmp_chr.data.spicevmc)
+ continue;
+ break;
+
+ default:
+ /* Unlikely, currently redirdev only supports character device of
+ * type "tcp" and "spicevmc".
+ */
+ break;
+ }
+
+ if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ !virDomainDeviceInfoAddressIsEqual(&redirdev->info, &tmp->info))
+ continue;
+
+ break;
+ }
+
+ if (i < def->nredirdevs)
+ return i;
+
+ return -1;
+}
+
+virDomainRedirdevDefPtr
+virDomainRedirdevRemove(virDomainDefPtr def,
+ size_t idx)
+{
+ virDomainRedirdevDefPtr ret = def->redirdevs[idx];
+
+ VIR_DELETE_ELEMENT(def->redirdevs, idx, def->nredirdevs);
+
+ return ret;
+}
char *
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1de3be3..03c0155 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2538,6 +2538,10 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
void virDomainHubDefFree(virDomainHubDefPtr def);
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
+ssize_t virDomainRedirdevFind(virDomainDefPtr def,
+ virDomainRedirdevDefPtr redirdev);
+virDomainRedirdevDefPtr virDomainRedirdevRemove(virDomainDefPtr def,
+ size_t idx);
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
void virDomainShmemDefFree(virDomainShmemDefPtr def);
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 4b40612..ad7d82c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -423,6 +423,9 @@ virDomainPMSuspendedReasonTypeFromString;
virDomainPMSuspendedReasonTypeToString;
virDomainRedirdevBusTypeFromString;
virDomainRedirdevBusTypeToString;
+virDomainRedirdevDefFree;
+virDomainRedirdevFind;
+virDomainRedirdevRemove;
virDomainRNGBackendTypeToString;
virDomainRNGDefFree;
virDomainRNGFind;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 45ff3c0..8905af6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7736,6 +7736,9 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_MEMORY:
ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory);
break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev);
+ break;
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
@@ -7748,7 +7751,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_SHMEM:
- case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dc76268..bbe8aa7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3287,6 +3287,49 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
}
+static int
+qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virObjectEventPtr event;
+ char *charAlias = NULL;
+ ssize_t idx;
+ int rc;
+ int ret = -1;
+
+ VIR_DEBUG("Removing redirdev device %s from domain %p %s",
+ redirdev->info.alias, vm, vm->def->name);
+
+ if (virAsprintf(&charAlias, "char%s", redirdev->info.alias) < 0)
+ return -1;
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ goto cleanup;
+
+ virDomainAuditRedirdev(vm, redirdev, "detach", rc == 0);
+
+ if (rc < 0)
+ goto cleanup;
+
+ event = virDomainEventDeviceRemovedNewFromObj(vm, redirdev->info.alias);
+ qemuDomainEventQueue(driver, event);
+
+ if ((idx = virDomainRedirdevFind(vm->def, redirdev)) >= 0)
+ virDomainRedirdevRemove(vm->def, idx);
+ qemuDomainReleaseDeviceAddress(vm, &redirdev->info, NULL);
+ virDomainRedirdevDefFree(redirdev);
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(charAlias);
+ return ret;
+}
+
int
qemuDomainRemoveDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -3318,6 +3361,10 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
ret = qemuDomainRemoveMemoryDevice(driver, vm, dev->data.memory);
break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ ret = qemuDomainRemoveRedirdevDevice(driver, vm, dev->data.redirdev);
+ break;
+
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
@@ -3327,7 +3374,6 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
- case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
@@ -4318,3 +4364,52 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
qemuDomainResetDeviceRemoval(vm);
return ret;
}
+
+int
+qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virDomainRedirdevDefPtr tmp;
+ ssize_t idx;
+ int rc;
+ int ret = -1;
+
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("qemu does not support -device"));
+ return -1;
+ }
+
+ if ((idx = virDomainRedirdevFind(vm->def, redirdev)) < 0) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("device not present in domain configuration"));
+ return -1;
+ }
+
+ tmp = vm->def->redirdevs[idx];
+
+ if (!tmp->info.alias) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("alias not set for redirdev device"));
+ return -1;
+ }
+
+ qemuDomainMarkDeviceForRemoval(vm, &tmp->info);
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rc = qemuMonitorDelDevice(priv->mon, tmp->info.alias);
+ if (qemuDomainObjExitMonitor(driver, vm) || rc < 0)
+ goto cleanup;
+
+ rc = qemuDomainWaitForDeviceRemoval(vm);
+ if (rc == 0 || rc == 1)
+ ret = qemuDomainRemoveRedirdevDevice(driver, vm, tmp);
+ else
+ ret = 0;
+
+ cleanup:
+ qemuDomainResetDeviceRemoval(vm);
+ return ret;
+}
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 4140da3..4ef42e9 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -51,6 +51,9 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainRedirdevDefPtr hostdev);
+int qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev);
int qemuDomainAttachHostDevice(virConnectPtr conn,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
--
2.1.4
8 years, 8 months