[libvirt] [PATCH v3 00/16] qemu: migration: show disks stats for nbd migration
by Nikolay Shirokovskiy
diff from v2:
============
1. Fix style issues.
2. Rework patch for fetching job info
(save logic to use temporary variable when drop vm lock)
3. Update disk stats when block jobs are canceled.
4. Adress a few more corner cases.
This patch series add disks stats to domain job info(stats) as
well as to migration completed event in case nbd scheme is used.
There is little nuisance with qcow2 disks (which is the main scenario
I guess) tied to the way qemu reports stats for this type of disks.
For example if we have 64G disk filled only to 1G then stats
start from 63G and will grow up to 64G on completion. The same way disk stats
will be reported by this patch.
I guess the better way to express the situation is to say we have 64G 'total',
and have 'processed' field grow from 0G to 1G, like in case of memory
stats. [1] is the example of completed memory stats of empty guest
domain, which show difference between processed and total.
There can be a workaround like getting initial blockjob offset position
as a zero but is is rather ugly and racy and like uses undocumented
behaviour.
[1] memory migration stats example
Memory processed: 3.307 MiB
Memory remaining: 0.000 B
Memory total: 1.032 GiB
The above is applied to qemu 2.6 at least.
Patches that were explicitly ACKed in previous review
(up to style issues) marked with A.
Nikolay Shirokovskiy (16):
qemu: drop code for VIR_DOMAIN_JOB_BOUNDED and timeRemaining
A qemu: introduce qemu domain job status
A qemu: introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY
A qemu: drop QEMU_MIGRATION_COMPLETED_UPDATE_STATS
A qemu: drop excessive zero-out in qemuMigrationFetchJobStatus
qemu: refactor fetching migration stats
A qemu: simplify getting completed job stats
qemu: fail querying destination migration statistics always
qemu: start all async job with job status active
qemu: introduce migrating job status
qemu: always get job condition on getting job stats
qemu: migrate: show disks stats on job info requests
qemu: support getting disks stats during stopping block jobs
qemu: migation: resolve race on getting job info and stopping block jobs
qemu: migrate: copy disks stats to completed job
qemu: migration: don't expose incomplete job as complete
src/qemu/qemu_blockjob.c | 1 +
src/qemu/qemu_domain.c | 38 +++++--
src/qemu/qemu_domain.h | 16 ++-
src/qemu/qemu_driver.c | 95 ++++++++--------
src/qemu/qemu_migration.c | 236 ++++++++++++++++++++++++++-------------
src/qemu/qemu_migration.h | 15 ++-
src/qemu/qemu_migration_cookie.c | 7 +-
src/qemu/qemu_monitor.c | 5 +-
src/qemu/qemu_monitor.h | 4 +-
src/qemu/qemu_monitor_json.c | 4 +-
src/qemu/qemu_process.c | 10 +-
tests/qemumonitorjsontest.c | 1 +
12 files changed, 273 insertions(+), 159 deletions(-)
--
1.8.3.1
7 years, 4 months
[libvirt] [PATCH] qemu: handle missing bind host/service on chardev hotplug
by Ján Tomko
On domain startup, bind host or bind service can be omitted
and we will format a working command line.
Extend this to hotplug as well and specify the service to QEMU
even if the host is missing.
https://bugzilla.redhat.com/show_bug.cgi?id=1452441
---
src/qemu/qemu_monitor_json.c | 13 ++++++++++---
tests/qemumonitorjsontest.c | 11 +++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0837290..ca9bb14 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6429,6 +6429,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
virJSONValuePtr data = NULL;
virJSONValuePtr addr = NULL;
const char *backend_type = NULL;
+ const char *host;
+ const char *port;
char *tlsalias = NULL;
bool telnet;
@@ -6492,9 +6494,14 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
virJSONValueObjectAppend(data, "remote", addr) < 0)
goto error;
- if (chr->data.udp.bindHost) {
- addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.udp.bindHost,
- chr->data.udp.bindService);
+ host = chr->data.udp.bindHost;
+ port = chr->data.udp.bindService;
+ if (host || port) {
+ if (!host)
+ host = "";
+ if (!port)
+ port = "";
+ addr = qemuMonitorJSONBuildInetSocketAddress(host, port);
if (!addr ||
virJSONValueObjectAppend(data, "local", addr) < 0)
goto error;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index e9f9d47..3de901c 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -895,6 +895,17 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
"'data':{'host':'localhost',"
"'port':'4321'}}}}}");
+ chr.data.udp.bindHost = NULL;
+ chr.data.udp.bindService = (char *) "4321";
+ CHECK("udp", false,
+ "{'id':'alias',"
+ "'backend':{'type':'udp',"
+ "'data':{'remote':{'type':'inet',"
+ "'data':{'host':'example.com',"
+ "'port':'1234'}},"
+ "'local':{'type':'inet',"
+ "'data':{'host':'',"
+ "'port':'4321'}}}}}");
memset(&chr, 0, sizeof(chr));
chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
chr.data.nix.path = (char *) "/path/to/socket";
--
2.10.2
7 years, 4 months
[libvirt] [PATCH] qemu: Use iohelper during restore
by Shivaprasad G Bhat
Commit afe6e58 & c4caab53 made necessary changes to use io-helpers
during save and restore. The commit c4caab53 missed to remove the
redundant check in qemuDomainSaveImageOpen() because of which
virFileWrapperFdNew() is not called if bypass_cache is false.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 516a851..ac89372 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6150,9 +6150,11 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
virDomainDefPtr def = NULL;
int oflags = open_write ? O_RDWR : O_RDONLY;
virCapsPtr caps = NULL;
+ unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
if (bypass_cache) {
int directFlag = virFileDirectFdFlag();
+ wrapperFlags |= VIR_FILE_WRAPPER_BYPASS_CACHE;
if (directFlag < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("bypass cache unsupported by this system"));
@@ -6166,9 +6168,8 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
if ((fd = qemuOpenFile(driver, NULL, path, oflags, NULL, NULL)) < 0)
goto error;
- if (bypass_cache &&
- !(*wrapperFd = virFileWrapperFdNew(&fd, path,
- VIR_FILE_WRAPPER_BYPASS_CACHE)))
+ if (wrapperFd &&
+ !(*wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
goto error;
if (saferead(fd, &header, sizeof(header)) != sizeof(header)) {
7 years, 4 months
[libvirt] Various apparmor related changes (part 2)
by Stefan Bader
> Over the years there have been a bunch of changes to the
> apparmor profiles and/or virt-aa-helper which have been
> carried in Debian/Ubuntu but never made it upstream.
>
> In an attempt to clean this up and generally improve the
> apparmor based environments, we (Christian and I) went
> over the changes, cleaned out cruft as much as possible
> and would be sending out hunks of changes to this list
> for upstream inclusion.
>
This second batch consists partially of some reworked
patches from the previous round and some more things
which hopefully are simple enough and improve the upstream
profiles.
5+6: Although these are Debian/Ubuntu specific, there are
other paths which are specific for SuSE. So I wondered
why not have both upstream.
9: Jamie, I know it has been a long time but do you remember
what this resolved?
Thanks,
Stefan
7 years, 5 months
[libvirt] [PATCH v2 0/4] fix labeling for chardev source path
by Pavel Hrdina
Pavel Hrdina (4):
conf: move seclabel for chardev source to the correct sturcture
qemu: introduce chardevStdioLogd to qemu private data
qemu: propagate chardevStdioLogd to qemuBuildChrChardevStr
security: don't relabel chardev source if virtlogd is used as stdio
handler
src/conf/domain_conf.c | 46 +++++++-------
src/conf/domain_conf.h | 9 +--
src/lxc/lxc_process.c | 6 +-
src/qemu/qemu_command.c | 132 ++++++++++++++++++++++++++-------------
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_domain.c | 6 ++
src/qemu/qemu_domain.h | 3 +
src/qemu/qemu_process.c | 15 ++++-
src/qemu/qemu_security.c | 9 ++-
src/security/security_apparmor.c | 7 ++-
src/security/security_dac.c | 74 +++++++++++++++-------
src/security/security_driver.h | 6 +-
src/security/security_manager.c | 16 +++--
src/security/security_manager.h | 6 +-
src/security/security_nop.c | 6 +-
src/security/security_selinux.c | 71 ++++++++++++++-------
src/security/security_stack.c | 12 ++--
tests/securityselinuxlabeltest.c | 2 +-
18 files changed, 281 insertions(+), 148 deletions(-)
--
2.13.0
7 years, 5 months
[libvirt] [PATCH 1/3] bhyve: tests: add vnc test to bhyvexml2xmltest
by Roman Bogorodskiy
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc.xml | 41 +++++++++++++++++++++++
tests/bhyvexml2xmltest.c | 3 +-
2 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc.xml
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc.xml
new file mode 100644
index 000000000..9e470e432
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc.xml
@@ -0,0 +1,41 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='gop' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index d591576ca..b3759919e 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -104,6 +104,7 @@ mymain(void)
DO_TEST_DIFFERENT("serial");
DO_TEST_DIFFERENT("serial-grub");
DO_TEST_DIFFERENT("serial-grub-nocons");
+ DO_TEST_DIFFERENT("vnc");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
@@ -127,7 +128,7 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
-VIR_TEST_MAIN(mymain)
+VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/bhyvexml2argvmock.so")
#else
--
2.12.1
7 years, 5 months
[libvirt] [PATCH] qemu: hotplug: Release address properly when redirected device attach failure
by Shivaprasad G Bhat
The virDomainUSBAddressEnsure returns 0 or -1 and checking for 1 is wrong.
Fix it.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_hotplug.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4a7d997..f339148 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1707,7 +1707,6 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn,
virDomainRedirdevDefPtr redirdev)
{
int ret = -1;
- int rc;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
char *charAlias = NULL;
@@ -1724,10 +1723,9 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn,
if (!(charAlias = qemuAliasChardevFromDevAlias(redirdev->info.alias)))
goto cleanup;
- if ((rc = virDomainUSBAddressEnsure(priv->usbaddrs, &redirdev->info)) < 0)
+ if ((virDomainUSBAddressEnsure(priv->usbaddrs, &redirdev->info)) < 0)
goto cleanup;
- if (rc == 1)
- need_release = true;
+ need_release = true;
if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps)))
goto cleanup;
7 years, 5 months
[libvirt] [PATCH] bhyve: add support for video device configuration
by Roman Bogorodskiy
Connect domain XML <driver vgaconf=""> configuration (introduced in a
previous patch) to bhyve command generation.
Unfortunately, this option was documented just recently and at the time
of writing official online manpages didn't have it updated, so for now
one can refer to:
https://github.com/freebsd/freebsd/blob/master/usr.sbin/bhyve/bhyve.8#L327
for the detailed description of the possible vga configuration options.
Also, add some tests for this new feature.
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
src/bhyve/bhyve_command.c | 4 ++
.../bhyvexml2argv-vnc-vgaconf.args | 12 ++++++
.../bhyvexml2argv-vnc-vgaconf.ldargs | 1 +
.../bhyvexml2argv-vnc-vgaconf.xml | 31 ++++++++++++++++
tests/bhyvexml2argvtest.c | 1 +
.../bhyvexml2xmlout-vnc-vgaconf.xml | 43 ++++++++++++++++++++++
tests/bhyvexml2xmltest.c | 1 +
7 files changed, 93 insertions(+)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf.xml
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index eae5cb3ca..f70e3bc60 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -408,6 +408,10 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
_("Unsupported listen type"));
}
+ if (video->driver)
+ virBufferAsprintf(&opt, ",vga=%s",
+ virDomainVideoVgaconfTypeToString(video->driver->vgaconf));
+
virCommandAddArg(cmd, "-s");
virCommandAddArgBuffer(cmd, &opt);
return 0;
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.args
new file mode 100644
index 000000000..70347ee0b
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.args
@@ -0,0 +1,12 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904,vga=off \
+-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.ldargs
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.xml
new file mode 100644
index 000000000..f1bcd1bde
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf.xml
@@ -0,0 +1,31 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='gop' heads='1' primary='yes'>
+ <driver vgaconf='off'/>
+ </model>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index c8f8c685a..a369a447a 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -193,6 +193,7 @@ mymain(void)
DO_TEST("net-e1000");
DO_TEST("uefi");
DO_TEST("vnc");
+ DO_TEST("vnc-vgaconf");
/* Address allocation tests */
DO_TEST("addr-single-sata-disk");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf.xml
new file mode 100644
index 000000000..6cc1aa088
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf.xml
@@ -0,0 +1,43 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='gop' heads='1' primary='yes'>
+ <driver vgaconf='off'/>
+ </model>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index b3759919e..70e4caeb3 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -105,6 +105,7 @@ mymain(void)
DO_TEST_DIFFERENT("serial-grub");
DO_TEST_DIFFERENT("serial-grub-nocons");
DO_TEST_DIFFERENT("vnc");
+ DO_TEST_DIFFERENT("vnc-vgaconf");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
--
2.12.1
7 years, 5 months
[libvirt] [PATCH 1/2] conf: add video driver configuration element
by Roman Bogorodskiy
Add support for video driver configuration. In domain xml it looks like
this:
<video>
<model type=''>
<driver .../>
</model>
</video>
At present, the only supported configuration is 'vgaconf' that looks this way:
<driver vgaconf='io|on|off'>
It was added with bhyve gop video in mind to allow users control how the
video device is exposed to the guest, specifically, how VGA I/O is
handled.
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
docs/schemas/domaincommon.rng | 13 +++++++++
src/conf/domain_conf.c | 63 +++++++++++++++++++++++++++++++++++++++++--
src/conf/domain_conf.h | 17 ++++++++++++
src/libvirt_private.syms | 2 ++
4 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 281309ec0..f45820383 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3278,6 +3278,19 @@
</optional>
</element>
</optional>
+ <optional>
+ <element name="driver">
+ <optional>
+ <attribute name="vgaconf">
+ <choice>
+ <value>io</value>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
</element>
</optional>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0ff216e3a..2ab55b52f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -553,6 +553,11 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"virtio",
"gop")
+VIR_ENUM_IMPL(virDomainVideoVgaconf, VIR_DOMAIN_VIDEO_VGACONF_LAST,
+ "io",
+ "on",
+ "off")
+
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
"mouse",
"tablet",
@@ -2280,6 +2285,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->accel);
+ VIR_FREE(def->driver);
VIR_FREE(def);
}
@@ -13368,6 +13374,43 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
return def;
}
+static virDomainVideoDriverDefPtr
+virDomainVideoDriverDefParseXML(xmlNodePtr node)
+{
+ xmlNodePtr cur;
+ virDomainVideoDriverDefPtr def;
+ char *vgaconf = NULL;
+ int val;
+
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (!vgaconf &&
+ xmlStrEqual(cur->name, BAD_CAST "driver")) {
+ vgaconf = virXMLPropString(cur, "vgaconf");
+ }
+ }
+ cur = cur->next;
+ }
+
+ if (!vgaconf)
+ return NULL;
+
+ if (VIR_ALLOC(def) < 0)
+ goto cleanup;
+
+ if ((val = virDomainVideoVgaconfTypeFromString(vgaconf)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown vgaconf value '%s'"), vgaconf);
+ goto cleanup;
+ }
+ def->vgaconf = val;
+
+ cleanup:
+ VIR_FREE(vgaconf);
+ return def;
+}
+
static virDomainVideoDefPtr
virDomainVideoDefParseXML(xmlNodePtr node,
const virDomainDef *dom,
@@ -13405,6 +13448,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
}
def->accel = virDomainVideoAccelDefParseXML(cur);
+ def->driver = virDomainVideoDriverDefParseXML(cur);
}
}
cur = cur->next;
@@ -22998,6 +23042,18 @@ virDomainVideoAccelDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
+static void
+virDomainVideoDriverDefFormat(virBufferPtr buf,
+ virDomainVideoDriverDefPtr def)
+{
+ virBufferAddLit(buf, "<driver");
+ if (def->vgaconf) {
+ virBufferAsprintf(buf, " vgaconf='%s'",
+ virDomainVideoVgaconfTypeToString(def->vgaconf));
+ }
+ virBufferAddLit(buf, "/>\n");
+}
+
static int
virDomainVideoDefFormat(virBufferPtr buf,
@@ -23028,10 +23084,13 @@ virDomainVideoDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " heads='%u'", def->heads);
if (def->primary)
virBufferAddLit(buf, " primary='yes'");
- if (def->accel) {
+ if (def->accel || def->driver) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
- virDomainVideoAccelDefFormat(buf, def->accel);
+ if (def->accel)
+ virDomainVideoAccelDefFormat(buf, def->accel);
+ if (def->driver)
+ virDomainVideoDriverDefFormat(buf, def->driver);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</model>\n");
} else {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 09fb7aada..cbf25a67b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1350,6 +1350,16 @@ typedef enum {
} virDomainVideoType;
+typedef enum {
+ VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
+ VIR_DOMAIN_VIDEO_VGACONF_ON,
+ VIR_DOMAIN_VIDEO_VGACONF_OFF,
+
+ VIR_DOMAIN_VIDEO_VGACONF_LAST
+} virDomainVideoVgaconf;
+
+VIR_ENUM_DECL(virDomainVideoVgaconf)
+
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
@@ -1358,6 +1368,12 @@ struct _virDomainVideoAccelDef {
};
+typedef struct _virDomainVideoDriverDef virDomainVideoDriverDef;
+typedef virDomainVideoDriverDef *virDomainVideoDriverDefPtr;
+struct _virDomainVideoDriverDef {
+ virDomainVideoVgaconf vgaconf;
+};
+
struct _virDomainVideoDef {
int type;
unsigned int ram; /* kibibytes (multiples of 1024) */
@@ -1367,6 +1383,7 @@ struct _virDomainVideoDef {
unsigned int heads;
bool primary;
virDomainVideoAccelDefPtr accel;
+ virDomainVideoDriverDefPtr driver;
virDomainDeviceInfo info;
};
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e6901a8f1..40995533c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -525,6 +525,8 @@ virDomainVideoDefaultType;
virDomainVideoDefFree;
virDomainVideoTypeFromString;
virDomainVideoTypeToString;
+virDomainVideoVgaconfTypeFromString;
+virDomainVideoVgaconfTypeToString;
virDomainVirtTypeFromString;
virDomainVirtTypeToString;
virDomainWatchdogActionTypeFromString;
--
2.12.1
7 years, 5 months
[libvirt] [PATCH 1/2] util: rename qemuGetProcessInfo to virProcessGetStat
by Wang King
qemuGetProcessInfo is more likely a process utility function, just rename it
to virProcessGetStat and move it to virprocess.c source file.
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 83 ++++++++++--------------------------------------
src/util/virprocess.c | 62 ++++++++++++++++++++++++++++++++++++
src/util/virprocess.h | 4 +++
4 files changed, 83 insertions(+), 67 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d361454..3681869 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2382,6 +2382,7 @@ virProcessGetMaxMemLock;
virProcessGetNamespaces;
virProcessGetPids;
virProcessGetStartTime;
+virProcessGetStat;
virProcessKill;
virProcessKillPainfully;
virProcessNamespaceAvailable;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6c79d4f..a4aa5da 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1378,68 +1378,6 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
return ret;
}
-
-static int
-qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
- pid_t pid, int tid)
-{
- char *proc;
- FILE *pidinfo;
- unsigned long long usertime = 0, systime = 0;
- long rss = 0;
- int cpu = 0;
- int ret;
-
- /* In general, we cannot assume pid_t fits in int; but /proc parsing
- * is specific to Linux where int works fine. */
- if (tid)
- ret = virAsprintf(&proc, "/proc/%d/task/%d/stat", (int) pid, tid);
- else
- ret = virAsprintf(&proc, "/proc/%d/stat", (int) pid);
- if (ret < 0)
- return -1;
-
- pidinfo = fopen(proc, "r");
- VIR_FREE(proc);
-
- /* See 'man proc' for information about what all these fields are. We're
- * only interested in a very few of them */
- if (!pidinfo ||
- fscanf(pidinfo,
- /* pid -> stime */
- "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu"
- /* cutime -> endcode */
- "%*d %*d %*d %*d %*d %*d %*u %*u %ld %*u %*u %*u"
- /* startstack -> processor */
- "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d",
- &usertime, &systime, &rss, &cpu) != 4) {
- VIR_WARN("cannot parse process status data");
- }
-
- /* We got jiffies
- * We want nanoseconds
- * _SC_CLK_TCK is jiffies per second
- * So calculate thus....
- */
- if (cpuTime)
- *cpuTime = 1000ull * 1000ull * 1000ull * (usertime + systime)
- / (unsigned long long)sysconf(_SC_CLK_TCK);
- if (lastCpu)
- *lastCpu = cpu;
-
- if (vm_rss)
- *vm_rss = rss * virGetSystemPageSizeKB();
-
-
- VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d rss=%ld",
- (int) pid, tid, usertime, systime, cpu, rss);
-
- VIR_FORCE_FCLOSE(pidinfo);
-
- return 0;
-}
-
-
static int
qemuDomainHelperGetVcpus(virDomainObjPtr vm,
virVcpuInfoPtr info,
@@ -1482,9 +1420,9 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
vcpuinfo->number = i;
vcpuinfo->state = VIR_VCPU_RUNNING;
- if (qemuGetProcessInfo(&vcpuinfo->cpuTime,
- &vcpuinfo->cpu, NULL,
- vm->pid, vcpupid) < 0) {
+ if (virProcessGetStat(vm->pid, vcpupid,
+ &vcpuinfo->cpuTime,
+ &vcpuinfo->cpu, NULL) < 0) {
virReportSystemError(errno, "%s",
_("cannot get vCPU placement & pCPU time"));
return -1;
@@ -2641,7 +2579,7 @@ qemuDomainGetInfo(virDomainPtr dom,
}
if (virDomainObjIsActive(vm)) {
- if (qemuGetProcessInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0) < 0) {
+ if (virProcessGetStat(vm->pid, 0, &(info->cpuTime), NULL, NULL) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot read cputime for domain"));
goto cleanup;
@@ -8172,6 +8110,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
int ret = -1;
+ virQEMUCapsPtr qemuCaps = NULL;
+ qemuDomainObjPrivatePtr priv;
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
@@ -8190,6 +8130,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup;
+ priv = vm->privateData;
+
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
@@ -8216,6 +8158,12 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
goto endjob;
}
+ if (priv->qemuCaps)
+ qemuCaps = virObjectRef(priv->qemuCaps);
+ else if (!(qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache,
+ vm->def->emulator)))
+ goto endjob;
+
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
@@ -8263,6 +8211,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
+ virObjectUnref(qemuCaps);
virDomainDefFree(vmdef);
if (dev != dev_copy)
virDomainDeviceDefFree(dev_copy);
@@ -11107,7 +11056,7 @@ qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver,
ret = 0;
}
- if (qemuGetProcessInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
+ if (virProcessGetStat(vm->pid, 0, NULL, NULL, &rss) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot get RSS for domain"));
} else {
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 1fbbbb3..98f4b25 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1426,3 +1426,65 @@ virProcessSetScheduler(pid_t pid ATTRIBUTE_UNUSED,
}
#endif /* !HAVE_SCHED_SETSCHEDULER */
+
+int
+virProcessGetStat(pid_t pid, int tid,
+ unsigned long long *cpuTime,
+ int *lastCpu, long *vm_rss)
+{
+ char *proc;
+ FILE *pidinfo;
+ unsigned long long usertime = 0, systime = 0;
+ long rss = 0;
+ int cpu = 0;
+ int ret;
+
+ /* In general, we cannot assume pid_t fits in int; but /proc parsing
+ * is specific to Linux where int works fine. */
+ if (tid)
+ ret = virAsprintf(&proc, "/proc/%d/task/%d/stat", (int) pid, tid);
+ else
+ ret = virAsprintf(&proc, "/proc/%d/stat", (int) pid);
+ if (ret < 0)
+ return -1;
+
+ pidinfo = fopen(proc, "r");
+ VIR_FREE(proc);
+
+ /* See 'man proc' for information about what all these fields are. We're
+ * only interested in a very few of them */
+ if (!pidinfo ||
+ fscanf(pidinfo,
+ /* pid -> stime */
+ "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu"
+ /* cutime -> endcode */
+ "%*d %*d %*d %*d %*d %*d %*u %*u %ld %*u %*u %*u"
+ /* startstack -> processor */
+ "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d",
+ &usertime, &systime, &rss, &cpu) != 4) {
+ VIR_WARN("cannot parse process status data");
+ }
+
+ /* We got jiffies
+ * We want nanoseconds
+ * _SC_CLK_TCK is jiffies per second
+ * So calculate thus....
+ */
+ if (cpuTime)
+ *cpuTime = 1000ull * 1000ull * 1000ull * (usertime + systime)
+ / (unsigned long long)sysconf(_SC_CLK_TCK);
+ if (lastCpu)
+ *lastCpu = cpu;
+
+ if (vm_rss)
+ *vm_rss = rss * virGetSystemPageSizeKB();
+
+
+ VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d rss=%ld",
+ (int) pid, tid, usertime, systime, cpu, rss);
+
+ VIR_FORCE_FCLOSE(pidinfo);
+
+ return 0;
+
+}
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
index 3c5a882..2a2b91d 100644
--- a/src/util/virprocess.h
+++ b/src/util/virprocess.h
@@ -106,4 +106,8 @@ typedef enum {
int virProcessNamespaceAvailable(unsigned int ns);
+int virProcessGetStat(pid_t pid, int tid,
+ unsigned long long *cpuTime,
+ int *lastCpu, long *vm_rss);
+
#endif /* __VIR_PROCESS_H__ */
--
2.8.3
7 years, 5 months