[libvirt] [PATCH 0/4] virsh: Provide better auto-completion
by Nishith Shah
This series of patches are meant to improve existing auto-complete
functionality in virsh.
The first patch breaks vshCmddefOptParse into two smaller functions, for
use later in the third patch.
The second patch simply changes the types of variables used in existing
readline generators.
The third patch introduces quiet mode for the functions vshCmddefGetOption
and vshCommandStringGetArg.
The fourth patch introduces vshReadlineParse, which uses existing parsing
functions and borrows from vshCommandParse to quite some extent and provides
better auto-completion.
Nishith Shah (4):
virsh: Break vshCmddefOptParse into helper functions
virsh: Fix variable types in readline generators
virsh: Add option to suppress error in various functions
virsh: Introduce vshReadlineParse for improved auto-completion
tools/vsh.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 271 insertions(+), 47 deletions(-)
--
2.7.4
8 years, 4 months
[libvirt] [PATCH] bhyve: implement virConnectGetDomainCapabilities
by Fabian Freyer
This patch adds virConnectGetDomainCapabilities support for bhyve.
---
src/bhyve/bhyve_capabilities.c | 26 ++++++++++++++++++++
src/bhyve/bhyve_capabilities.h | 5 ++++
src/bhyve/bhyve_driver.c | 56 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+)
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index d0af4d9..10c33b9 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2014 Roman Bogorodskiy
* Copyright (C) 2014 Semihalf
+ * Copyright (C) 2016 Fabian Freyer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -106,6 +107,31 @@ virBhyveCapsBuild(void)
return NULL;
}
+virDomainCapsPtr
+virBhyveDomainCapsBuild(const char *emulatorbin,
+ const char *machine,
+ virArch arch,
+ virDomainVirtType virttype)
+{
+ virDomainCapsPtr caps = NULL;
+
+ if (!(caps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
+ goto cleanup;
+
+ caps->os.supported = true;
+ caps->disk.supported = true;
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice,
+ VIR_DOMAIN_DISK_DEVICE_DISK,
+ VIR_DOMAIN_DISK_DEVICE_CDROM);
+
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.bus,
+ VIR_DOMAIN_DISK_BUS_SATA,
+ VIR_DOMAIN_DISK_BUS_VIRTIO);
+
+ cleanup:
+ return caps;
+}
+
int
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
{
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index 0eb22a4..85018cb 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -23,8 +23,13 @@
# define _BHYVE_CAPABILITIES
# include "capabilities.h"
+#include "conf/domain_capabilities.h"
virCapsPtr virBhyveCapsBuild(void);
+virDomainCapsPtr virBhyveDomainCapsBuild(const char *emulatorbin,
+ const char *machine,
+ virArch arch,
+ virDomainVirtType virttype);
/* These are bit flags: */
typedef enum {
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 8036661..ae37a2d 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -53,6 +53,7 @@
#include "nodeinfo.h"
#include "virhostcpu.h"
#include "virhostmem.h"
+#include "conf/domain_capabilities.h"
#include "bhyve_device.h"
#include "bhyve_driver.h"
@@ -1539,6 +1540,60 @@ bhyveConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
return 0;
}
+static char *
+bhyveConnectGetDomainCapabilities(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch_str,
+ const char *machine,
+ const char *virttype_str,
+ unsigned int flags)
+{
+ //bhyveConnPtr privconn = conn->privateData;
+ virDomainCapsPtr caps = NULL;
+ char *ret = NULL;
+ int virttype = VIR_DOMAIN_VIRT_BHYVE;
+ int arch = virArchFromHost(); /* virArch */
+
+ virCheckFlags(0, ret);
+
+ if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0)
+ return ret;
+
+ if (virttype_str &&
+ (virttype = virDomainVirtTypeFromString(virttype_str)) < 0) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown virttype: %s"),
+ virttype_str);
+ goto cleanup;
+ }
+
+ if (virttype != VIR_DOMAIN_VIRT_BHYVE) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown virttype: %s"),
+ virttype_str);
+ goto cleanup;
+ }
+
+ if (arch_str && (arch = virArchFromString(arch_str)) == VIR_ARCH_NONE) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown architecture: %s"),
+ arch_str);
+ goto cleanup;
+ }
+
+ if (emulatorbin == NULL)
+ emulatorbin = "/usr/sbin/bhyve";
+
+ if (!(caps = virBhyveDomainCapsBuild(emulatorbin, machine, arch, virttype)))
+ goto cleanup;
+
+ ret = virDomainCapsFormat(caps);
+
+ cleanup:
+ virObjectUnref(caps);
+ return ret;
+}
+
static virHypervisorDriver bhyveHypervisorDriver = {
.name = "bhyve",
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
@@ -1592,6 +1647,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
.connectIsAlive = bhyveConnectIsAlive, /* 1.3.5 */
.connectIsSecure = bhyveConnectIsSecure, /* 1.3.5 */
.connectIsEncrypted = bhyveConnectIsEncrypted, /* 1.3.5 */
+ .connectGetDomainCapabilities = bhyveConnectGetDomainCapabilities, /* 2.1.0 */
};
--
2.5.5
8 years, 4 months
[libvirt] [PATCH] bhyve: fix bhyveargv2xml custom loader test
by Roman Bogorodskiy
Before pushing this test, I changed the appropriate args file
to pet test-wrap-argv.pl, but forgot to change the xml file, so
update it accordingly.
---
Pushed as trivial.
tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml
index 3e9bd29..68a488f 100644
--- a/tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml
@@ -5,7 +5,7 @@
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<bootloader>/usr/bin/custom-loader</bootloader>
- <bootloader_args>with several arguments</bootloader_args>
+ <bootloader_args>-s ome --args</bootloader_args>
<os>
<type>hvm</type>
</os>
--
2.7.4
8 years, 4 months
[libvirt] [PATCH v5 0/6] bhyve: virConnectDomainXMLFromNative
by Fabian Freyer
Differences to v4:
- fixed various memory leaks
- various style improvements by Roman Bogorodskiy and fixes for his comments
on v4
Link to v4:
https://www.redhat.com/archives/libvir-list/2016-June/msg02138.html
Link to v3:
https://www.redhat.com/archives/libvir-list/2016-June/msg01741.html
Link to v2:
https://www.redhat.com/archives/libvir-list/2016-June/msg00728.html
Link to v1:
https://www.redhat.com/archives/libvir-list/2016-June/msg00001.html
Fabian Freyer (6):
config-post.h: define __GNUC_PREREQ if not defined
gnulib: add getopt module
bhyve: implement virConnectDomainXMLFromNative
bhyve: implement bhyve argument parser
bhyve: implement argument parser for loader
Add some tests for bhyveParseCommandLineString
bootstrap.conf | 1 +
config-post.h | 18 +
m4/virt-driver-bhyve.m4 | 3 +
po/POTFILES.in | 2 +
src/Makefile.am | 2 +
src/bhyve/bhyve_driver.c | 41 +
src/bhyve/bhyve_parse_command.c | 903 +++++++++++++++++++++
src/bhyve/bhyve_parse_command.h | 30 +
tests/Makefile.am | 23 +-
.../bhyveargv2xmldata/bhyveargv2xml-acpiapic.args | 9 +
tests/bhyveargv2xmldata/bhyveargv2xml-acpiapic.xml | 20 +
tests/bhyveargv2xmldata/bhyveargv2xml-ahci-hd.args | 8 +
tests/bhyveargv2xmldata/bhyveargv2xml-ahci-hd.xml | 21 +
tests/bhyveargv2xmldata/bhyveargv2xml-base.args | 7 +
tests/bhyveargv2xmldata/bhyveargv2xml-base.xml | 16 +
.../bhyveargv2xml-bhyveload-bootorder.args | 13 +
.../bhyveargv2xml-bhyveload-bootorder.xml | 27 +
.../bhyveargv2xml-bhyveload-custom.args | 11 +
.../bhyveargv2xml-bhyveload-custom.xml | 18 +
.../bhyveargv2xml-bhyveload-mem-mismatch.args | 12 +
.../bhyveargv2xml-bhyveload-memsize-fail.args | 12 +
.../bhyveargv2xml-bhyveload-name-mismatch.args | 12 +
.../bhyveargv2xml-bhyveload-vda.args | 12 +
.../bhyveargv2xml-bhyveload-vda.xml | 21 +
.../bhyveargv2xml-bhyverun-mem-mismatch.args | 12 +
.../bhyveargv2xml-bhyverun-name-mismatch.args | 12 +
tests/bhyveargv2xmldata/bhyveargv2xml-cdrom.args | 8 +
tests/bhyveargv2xmldata/bhyveargv2xml-cdrom.xml | 21 +
tests/bhyveargv2xmldata/bhyveargv2xml-console.args | 10 +
tests/bhyveargv2xmldata/bhyveargv2xml-console.xml | 24 +
.../bhyveargv2xmldata/bhyveargv2xml-console2.args | 10 +
tests/bhyveargv2xmldata/bhyveargv2xml-console2.xml | 15 +
.../bhyveargv2xmldata/bhyveargv2xml-console3.args | 11 +
tests/bhyveargv2xmldata/bhyveargv2xml-console3.xml | 27 +
.../bhyveargv2xmldata/bhyveargv2xml-console4.args | 10 +
tests/bhyveargv2xmldata/bhyveargv2xml-console4.xml | 15 +
.../bhyveargv2xml-custom-loader.args | 8 +
.../bhyveargv2xml-custom-loader.xml | 18 +
.../bhyveargv2xml-disk-toomany.args | 34 +
.../bhyveargv2xml-disk-toomany.xml | 146 ++++
.../bhyveargv2xmldata/bhyveargv2xml-extraargs.args | 8 +
.../bhyveargv2xml-memsize-fail.args | 7 +
.../bhyveargv2xml-memsize-human.args | 7 +
.../bhyveargv2xml-memsize-human.xml | 16 +
.../bhyveargv2xml-memsize-large.args | 7 +
.../bhyveargv2xml-memsize-large.xml | 16 +
tests/bhyveargv2xmldata/bhyveargv2xml-name.args | 7 +
tests/bhyveargv2xmldata/bhyveargv2xml-name.xml | 16 +
tests/bhyveargv2xmldata/bhyveargv2xml-oneline.args | 1 +
tests/bhyveargv2xmldata/bhyveargv2xml-oneline.xml | 16 +
tests/bhyveargv2xmldata/bhyveargv2xml-utc.args | 8 +
tests/bhyveargv2xmldata/bhyveargv2xml-utc.xml | 16 +
tests/bhyveargv2xmldata/bhyveargv2xml-uuid.args | 8 +
tests/bhyveargv2xmldata/bhyveargv2xml-uuid.xml | 16 +
tests/bhyveargv2xmldata/bhyveargv2xml-uuid2.args | 8 +
tests/bhyveargv2xmldata/bhyveargv2xml-vcpus.args | 7 +
tests/bhyveargv2xmldata/bhyveargv2xml-vcpus.xml | 16 +
.../bhyveargv2xml-virtio-blk.args | 8 +
.../bhyveargv2xmldata/bhyveargv2xml-virtio-blk.xml | 21 +
.../bhyveargv2xml-virtio-net.args | 9 +
.../bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml | 26 +
.../bhyveargv2xml-virtio-net2.args | 8 +
.../bhyveargv2xml-virtio-net2.xml | 16 +
.../bhyveargv2xml-virtio-net3.args | 8 +
.../bhyveargv2xml-virtio-net3.xml | 16 +
.../bhyveargv2xml-virtio-net4.args | 8 +
.../bhyveargv2xml-virtio-net4.xml | 21 +
tests/bhyveargv2xmlmock.c | 27 +
tests/bhyveargv2xmltest.c | 213 +++++
69 files changed, 2181 insertions(+), 3 deletions(-)
create mode 100644 src/bhyve/bhyve_parse_command.c
create mode 100644 src/bhyve/bhyve_parse_command.h
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-acpiapic.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-acpiapic.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-ahci-hd.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-ahci-hd.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-base.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-base.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-bootorder.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-bootorder.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-custom.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-custom.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-mem-mismatch.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-memsize-fail.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-name-mismatch.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-vda.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyveload-vda.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyverun-mem-mismatch.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-bhyverun-name-mismatch.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-cdrom.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-cdrom.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console2.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console2.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console3.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console3.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console4.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-console4.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-custom-loader.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-disk-toomany.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-disk-toomany.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-extraargs.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-memsize-fail.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-memsize-human.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-memsize-human.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-memsize-large.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-memsize-large.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-name.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-name.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-oneline.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-oneline.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-utc.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-utc.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-uuid.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-uuid.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-uuid2.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vcpus.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-vcpus.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-blk.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-blk.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net2.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net2.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net3.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net3.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml
create mode 100644 tests/bhyveargv2xmlmock.c
create mode 100644 tests/bhyveargv2xmltest.c
--
2.5.5
8 years, 4 months
[libvirt] [PATCH 00/10] Test persistent device attachment
by Tomasz Flendrich
This patch requires two other patches:
https://www.redhat.com/archives/libvir-list/2016-July/msg00264.html
https://www.redhat.com/archives/libvir-list/2016-July/msg00202.html
In qemu_driver.c, two functions were split to have less responsibility.
They were also modified so that they could be used in qemuhotplugtest.
Now instead of running different functions to attach different device
types, a generic function is run. Hopefully this will result in more
device types tested in the future.
Suggestions on how to name these two new functions are very welcome.
In the future, if one uses the following command:
virsh attach-device --live --config
the new device will have the same address assigned in both live
and config domain. To make sure that everything will work properly
after making these changes, I reworked qemuhotplug.c to work with
attaching devices to persistent domains.
So far, there is only one test for persistent attachment. I will
add more testcases as soon as I hear some feedback on these changes.
qemuhotplugtest.c should first be modified anyway, so that the three
xmls's filenames (basis domain xml, device xml, expected xml) are stated
explicitly instead of being calculated. This will allow for more
flexibility in testing and less xml files duplicates.
Tomasz
Tomasz Flendrich (10):
Change parameters to qemuDomainAttachDeviceLive
Remove an unnecessary variable
Split qemuDomainAttachDeviceFlags in two
Narrow down a parameter
Split qemuDomainDetachDeviceFlags in two
Make qemu attach/detach functions public
Narrow down a parameter to function
Use more generic functions in qemuhotplugtest
Make qemuhotplugtest work with persistent domains
Add a persistent attachment testcase
src/qemu/qemu_driver.c | 221 +++++++++++----------
src/qemu/qemu_driver.h | 14 ++
tests/qemuhotplugtest.c | 213 ++++++++++++--------
.../qemuhotplug-base-config+qemu-agent+config.xml | 45 +++++
.../qemuhotplug-base-config.xml | 40 ++++
5 files changed, 349 insertions(+), 184 deletions(-)
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-config+qemu-agent+config.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-config.xml
--
1.9.1
8 years, 4 months
[libvirt] [PATCH 0/3] bitmap: Clarify and add tests for empty bitmap
by Marc Hartmayer
This patch series clarifies the virBitmapLastSetBit function and adds some
tests for the empty bitmap.
It also clarifies the documentations of virBitmapNewQuiet and virBitmapNew.
Marc Hartmayer (3):
util: bitmap: clarify virBitmapLastSetBit() behavior for empty bitmaps
util: bitmap: Mention the size == 0 handling
tests: Add test cases for the empty bitmap
src/util/virbitmap.c | 18 +++++++++++-------
tests/virbitmaptest.c | 17 +++++++++++++++++
2 files changed, 28 insertions(+), 7 deletions(-)
--
2.5.5
8 years, 4 months
[libvirt] [PATCH] tests: env perl shebang for test-wrap-argv.pl
by Fabian Freyer
On some systems perl is not necessarily in /usr/bin/perl. Use the perl version
in the PATH instead.
---
tests/test-wrap-argv.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test-wrap-argv.pl b/tests/test-wrap-argv.pl
index d66f5b4..b053f28 100755
--- a/tests/test-wrap-argv.pl
+++ b/tests/test-wrap-argv.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
#
# Copyright (C) 2015 Red Hat, Inc.
#
--
2.5.5
8 years, 4 months
[libvirt] [PATCH 00/11] vCPU information storage improvements
by Peter Krempa
Cleanups and improvements that will make adding the new vCPU hotplug that was
recently added to qemu easier.
Peter Krempa (11):
conf: Annotate that private data for objects are not copied
conf: Extract code formatting vCPU info
conf: Rename virDomainVcpuInfoPtr to virDomainVcpuDefPtr
conf: Don't report errors from virDomainDefGetVcpu
tests: qemuxml2xml: Format status XML header dynamically
conf: convert def->vcpus to a array of pointers
conf: Add private data for virDomainVcpuDef
qemu: domain: Add vcpu private data structure
qemu: domain: Extract formating and parsing of vCPU thread ids
qemu: Add cpu ID to the vCPU pid list in the status XML
qemu: Store vCPU thread ids in vcpu private data objects
src/conf/domain_conf.c | 127 +++++++++++++++++---------
src/conf/domain_conf.h | 32 ++++---
src/hyperv/hyperv_driver.c | 3 +-
src/libxl/libxl_domain.c | 2 +-
src/libxl/libxl_driver.c | 6 +-
src/lxc/lxc_native.c | 2 +-
src/openvz/openvz_conf.c | 2 +-
src/openvz/openvz_driver.c | 16 ++--
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_cgroup.c | 2 +-
src/qemu/qemu_domain.c | 206 +++++++++++++++++++++++++++++++-----------
src/qemu/qemu_domain.h | 18 +++-
src/qemu/qemu_driver.c | 22 ++---
src/qemu/qemu_parse_command.c | 9 +-
src/qemu/qemu_process.c | 6 +-
src/test/test_driver.c | 8 +-
src/vbox/vbox_common.c | 4 +-
src/vmx/vmx.c | 2 +-
src/vz/vz_sdk.c | 2 +-
src/xen/xm_internal.c | 2 +-
src/xenapi/xenapi_driver.c | 2 +-
src/xenconfig/xen_common.c | 13 ++-
src/xenconfig/xen_common.h | 3 +-
src/xenconfig/xen_sxpr.c | 2 +-
src/xenconfig/xen_xl.c | 3 +-
src/xenconfig/xen_xm.c | 3 +-
tests/qemuxml2xmltest.c | 73 ++++++++++++---
27 files changed, 396 insertions(+), 176 deletions(-)
--
2.9.0
8 years, 4 months
[libvirt] [PATCH] qemu: report vcpu state in virDomainGetVcpus
by Boris Fiuczynski
From: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
Currently, the virVcpuInfo returned by virDomainGetVcpus() will always
report a state of VIR_VCPU_RUNNING for each defined domain vcpu even if
the vcpu is currently in the halted state.
As the monitor interface is in fact reporting the accurate state, it is
rather easy to transport this information with the existing API.
This is done by
- adding a new state of VIR_VCPU_HALTED
- extending the monitor to pass back the halted state for the vcpus
- adding a new array to the private domain object reflecting the halted
state for the vcpus and update it along with the vcpu pids array
- modifying the driver code to report the vcpu state based on the halted
indicator
- extending virsh vcpuinfo to also display the halted state
- modifying the monitor_json testcase
The vcpu state is however not recorded in the internal XML format, since
the state can change asynchronously (without notification).
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
---
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_domain.c | 26 +++++++++++++++++++++++++-
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 14 +++++++++++++-
src/qemu/qemu_monitor.c | 7 ++++---
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 22 +++++++++++++++++++---
src/qemu/qemu_monitor_json.h | 3 ++-
src/qemu/qemu_monitor_text.c | 17 +++++++++++++++--
src/qemu/qemu_monitor_text.h | 3 ++-
src/qemu/qemu_process.c | 1 +
tests/qemumonitorjsontest.c | 18 +++++++++++++++---
tools/virsh-domain.c | 3 ++-
13 files changed, 103 insertions(+), 17 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7ea93aa..98b9420 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1656,6 +1656,7 @@ typedef enum {
VIR_VCPU_OFFLINE = 0, /* the virtual CPU is offline */
VIR_VCPU_RUNNING = 1, /* the virtual CPU is running */
VIR_VCPU_BLOCKED = 2, /* the virtual CPU is blocked on resource */
+ VIR_VCPU_HALTED = 3, /* the virtual CPU is halted */
# ifdef VIR_ENUM_SENTINELS
VIR_VCPU_LAST
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 42b5511..3428605 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1256,6 +1256,7 @@ qemuDomainObjPrivateFree(void *data)
virDomainChrSourceDefFree(priv->monConfig);
qemuDomainObjFreeJob(priv);
VIR_FREE(priv->vcpupids);
+ VIR_FREE(priv->vcpuhalted);
VIR_FREE(priv->lockState);
VIR_FREE(priv->origname);
@@ -5470,6 +5471,7 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
int asyncJob)
{
pid_t *cpupids = NULL;
+ bool *cpuhalted = NULL;
int ncpupids = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -5506,7 +5508,7 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
- ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids);
+ ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids, &cpuhalted);
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
VIR_FREE(cpupids);
return -2;
@@ -5526,16 +5528,38 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
"got %d, wanted %d"),
ncpupids, virDomainDefGetVcpus(vm->def));
VIR_FREE(cpupids);
+ VIR_FREE(cpuhalted);
return -1;
}
done:
VIR_FREE(priv->vcpupids);
+ VIR_FREE(priv->vcpuhalted);
priv->nvcpupids = ncpupids;
priv->vcpupids = cpupids;
+ priv->vcpuhalted = cpuhalted;
return ncpupids;
}
+/**
+ * qemuDomainGetVcpuHalted:
+ * @vm: domain object
+ * @vcpu: cpu id
+ *
+ * Returns the vCPU halted state.
+ */
+bool
+qemuDomainGetVcpuHalted(virDomainObjPtr vm,
+ unsigned int vcpu)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ if (vcpu >= priv->nvcpupids)
+ return 0;
+
+ return priv->vcpuhalted[vcpu];
+}
+
bool
qemuDomainSupportsNicdev(virDomainDefPtr def,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index c49f31c..8f7d421 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -186,6 +186,7 @@ struct _qemuDomainObjPrivate {
int nvcpupids;
int *vcpupids;
+ bool *vcpuhalted;
virDomainPCIAddressSetPtr pciaddrs;
virDomainCCWAddressSetPtr ccwaddrs;
@@ -639,6 +640,7 @@ bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm,
int asyncJob);
+bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
virDomainNetDefPtr net);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f9a3b15..f7ea745 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1477,13 +1477,17 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) {
virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, i);
pid_t vcpupid = qemuDomainGetVcpuPid(vm, i);
+ bool vcpuhalted = qemuDomainGetVcpuHalted(vm, i);
if (!vcpu->online)
continue;
if (info) {
info[i].number = i;
- info[i].state = VIR_VCPU_RUNNING;
+ if (vcpuhalted)
+ info[i].state = VIR_VCPU_HALTED;
+ else
+ info[i].state = VIR_VCPU_RUNNING;
if (qemuGetProcessInfo(&(info[i].cpuTime), &(info[i].cpu), NULL,
vm->pid, vcpupid) < 0) {
@@ -5272,6 +5276,7 @@ qemuDomainGetVcpus(virDomainPtr dom,
unsigned char *cpumaps,
int maplen)
{
+ virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
int ret = -1;
@@ -5288,6 +5293,13 @@ qemuDomainGetVcpus(virDomainPtr dom,
goto cleanup;
}
+ if (qemuDomainDetectVcpuPids(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("could not detect vcpu pids"));
+ return -1;
+ }
+
ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen);
cleanup:
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 098e654..0272fb4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1656,14 +1656,15 @@ qemuMonitorSystemReset(qemuMonitorPtr mon)
*/
int
qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
- int **pids)
+ int **pids,
+ bool **haltpids)
{
QEMU_CHECK_MONITOR(mon);
if (mon->json)
- return qemuMonitorJSONGetCPUInfo(mon, pids);
+ return qemuMonitorJSONGetCPUInfo(mon, pids, haltpids);
else
- return qemuMonitorTextGetCPUInfo(mon, pids);
+ return qemuMonitorTextGetCPUInfo(mon, pids, haltpids);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index cb4cca8..9f6ef72 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -391,7 +391,8 @@ int qemuMonitorSystemReset(qemuMonitorPtr mon);
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
- int **pids);
+ int **pids,
+ bool **haltpids);
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
virDomainVirtType *virtType);
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index bb426dc..87343c0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1324,13 +1324,15 @@ int qemuMonitorJSONSystemReset(qemuMonitorPtr mon)
*/
static int
qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
- int **pids)
+ int **pids,
+ bool **haltpids)
{
virJSONValuePtr data;
int ret = -1;
size_t i;
int *threads = NULL;
ssize_t ncpus;
+ bool *haltedpids = NULL;
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1347,9 +1349,13 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
if (VIR_ALLOC_N(threads, ncpus) < 0)
goto cleanup;
+ if (VIR_ALLOC_N(haltedpids, ncpus) < 0)
+ goto cleanup;
+
for (i = 0; i < ncpus; i++) {
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
int thread;
+ bool halted;
if (!entry) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was missing an array element"));
@@ -1363,21 +1369,31 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
goto cleanup;
}
+ if (virJSONValueObjectGetBoolean(entry, "halted", &halted) < 0) {
+ /* Some older qemu versions may not report the halted state,
+ * for backword compatibility we assume it's not halted */
+ halted = false;
+ }
+
threads[i] = thread;
+ haltedpids[i] = halted;
}
*pids = threads;
+ *haltpids = haltedpids;
threads = NULL;
+ haltedpids = NULL;
ret = ncpus;
cleanup:
VIR_FREE(threads);
+ VIR_FREE(haltedpids);
return ret;
}
int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
- int **pids)
+ int **pids, bool **haltpids)
{
int ret = -1;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-cpus",
@@ -1395,7 +1411,7 @@ int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
- ret = qemuMonitorJSONExtractCPUInfo(reply, pids);
+ ret = qemuMonitorJSONExtractCPUInfo(reply, pids, haltpids);
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 37a739e..c7808aa 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -59,7 +59,8 @@ int qemuMonitorJSONSystemPowerdown(qemuMonitorPtr mon);
int qemuMonitorJSONSystemReset(qemuMonitorPtr mon);
int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
- int **pids);
+ int **pids,
+ bool **haltpids);
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
virDomainVirtType *virtType);
int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 9295219..fbacdbd 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -501,12 +501,15 @@ int qemuMonitorTextSystemReset(qemuMonitorPtr mon)
int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
- int **pids)
+ int **pids,
+ bool **haltpids)
{
char *qemucpus = NULL;
char *line;
pid_t *cpupids = NULL;
size_t ncpupids = 0;
+ bool *cpuhalted = NULL;
+ size_t ncpuhalted = 0;
if (qemuMonitorHMPCommand(mon, "info cpus", &qemucpus) < 0)
return -1;
@@ -517,7 +520,7 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
* (qemu) info cpus
* * CPU #0: pc=0x00000000000f0c4a thread_id=30019
* CPU #1: pc=0x00000000fffffff0 thread_id=30020
- * CPU #2: pc=0x00000000fffffff0 thread_id=30021
+ * CPU #2: pc=0x00000000fffffff0 (halted) thread_id=30021
*
*/
line = qemucpus;
@@ -525,6 +528,7 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
char *offset = NULL;
char *end = NULL;
int tid = 0;
+ bool halted = false;
/* Extract host Thread ID */
if ((offset = strstr(line, "thread_id=")) == NULL)
@@ -538,6 +542,13 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
if (VIR_APPEND_ELEMENT_COPY(cpupids, ncpupids, tid) < 0)
goto error;
+ /* Extract halted indicator */
+ if ((offset = strstr(line, "(halted)")) != NULL)
+ halted = true;
+
+ if (VIR_APPEND_ELEMENT_COPY(cpuhalted, ncpuhalted, halted) < 0)
+ goto error;
+
VIR_DEBUG("tid=%d", tid);
/* Skip to next data line */
@@ -549,11 +560,13 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
/* Validate we got data for all VCPUs we expected */
VIR_FREE(qemucpus);
*pids = cpupids;
+ *haltpids = cpuhalted;
return ncpupids;
error:
VIR_FREE(qemucpus);
VIR_FREE(cpupids);
+ VIR_FREE(cpuhalted);
/* Returning 0 to indicate non-fatal failure, since
* older QEMU does not have VCPU<->PID mapping and
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index eeaca52..e7009b3 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -50,7 +50,8 @@ int qemuMonitorTextSystemPowerdown(qemuMonitorPtr mon);
int qemuMonitorTextSystemReset(qemuMonitorPtr mon);
int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
- int **pids);
+ int **pids,
+ bool **haltpids);
int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
virDomainVirtType *virtType);
int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 129c070..403b332 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5900,6 +5900,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
vm->pid = -1;
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
VIR_FREE(priv->vcpupids);
+ VIR_FREE(priv->vcpuhalted);
priv->nvcpupids = 0;
for (i = 0; i < vm->def->niothreadids; i++)
vm->def->iothreadids[i]->thread_id = 0;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index f698c14..441720e 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1210,6 +1210,8 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUInfo(const void *data)
int ret = -1;
pid_t *cpupids = NULL;
pid_t expected_cpupids[] = {17622, 17624, 17626, 17628};
+ bool *cpuhalted = NULL;
+ bool expected_cpuhalted[] = {true, true, false, false};
int ncpupids;
size_t i;
@@ -1237,14 +1239,14 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUInfo(const void *data)
" \"current\": false,"
" \"CPU\": 2,"
" \"pc\": -2130530478,"
- " \"halted\": true,"
+ " \"halted\": false,"
" \"thread_id\": 17626"
" },"
" {"
" \"current\": false,"
" \"CPU\": 3,"
" \"pc\": -2130530478,"
- " \"halted\": true,"
+ " \"halted\": false,"
" \"thread_id\": 17628"
" }"
" ],"
@@ -1252,7 +1254,7 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUInfo(const void *data)
"}") < 0)
goto cleanup;
- ncpupids = qemuMonitorJSONGetCPUInfo(qemuMonitorTestGetMonitor(test), &cpupids);
+ ncpupids = qemuMonitorJSONGetCPUInfo(qemuMonitorTestGetMonitor(test), &cpupids, &cpuhalted);
if (ncpupids != 4) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1269,10 +1271,20 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUInfo(const void *data)
}
}
+ for (i = 0; i < ncpupids; i++) {
+ if (cpuhalted[i] != expected_cpuhalted[i]) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Expecting cpuhalted[%zu] = %d but got %d",
+ i, expected_cpuhalted[i], cpuhalted[i]);
+ goto cleanup;
+ }
+ }
+
ret = 0;
cleanup:
VIR_FREE(cpupids);
+ VIR_FREE(cpuhalted);
qemuMonitorTestFree(test);
return ret;
}
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index dbdee5b..4650eb3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -181,7 +181,8 @@ VIR_ENUM_IMPL(virshDomainVcpuState,
VIR_VCPU_LAST,
N_("offline"),
N_("running"),
- N_("blocked"))
+ N_("blocked"),
+ N_("halted"))
static const char *
virshDomainVcpuStateToString(int state)
--
2.9.0
8 years, 4 months