[libvirt] [PATCH] qemu/doc: Fix function name for handling events
by Philipp Hahn
Insert missing "IO" into function name.
---
src/qemu/EVENTHANDLERS.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/EVENTHANDLERS.txt b/src/qemu/EVENTHANDLERS.txt
index 79c1505caa..c7798d600b 100644
--- a/src/qemu/EVENTHANDLERS.txt
+++ b/src/qemu/EVENTHANDLERS.txt
@@ -17,7 +17,7 @@ other qemu events in the future.
----------------------------------------------------
Any event emitted by qemu is received by
-qemu_monitor_json.c:qemuMonitorJSONProcessEvent(). It looks up the
+qemu_monitor_json.c:qemuMonitorJSONIOProcessEvent(). It looks up the
event by name in the table eventHandlers (in the same file), which
should have an entry like this for each event that libvirt
understands:
--
2.11.0
7 years, 4 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, 4 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, 4 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, 4 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, 4 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, 4 months
[libvirt] [PATCH] qemu: Explain why mdevs are assumed to be PCI Express
by Andrea Bolognani
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain_address.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 2106b34..b5b863f 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -645,6 +645,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return pcieFlags;
}
+ /* mdevs don't have corresponding files in /sys that we can poke to
+ * try and figure out whether they are legacy PCI or PCI Express, so
+ * the logic below would never work; instead, we just go ahead and
+ * assume they're PCI Express. This is a very reasonable assumption,
+ * as all current mdev-capable devices are indeed PCI Express */
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV)
return pcieFlags;
--
2.7.5
7 years, 4 months
[libvirt] [PATCH 0/2] fix VNC and Spice unix socket escaping
by Pavel Hrdina
Pavel Hrdina (2):
qemu: skip only ',' for VNC and Spice unix socket
Revert "util: virqemu: introduce virQEMUBuildBufferEscape"
src/libvirt_private.syms | 1 -
src/qemu/qemu_command.c | 4 ++--
src/util/virqemu.c | 17 -----------------
src/util/virqemu.h | 1 -
tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 4 ++--
5 files changed, 4 insertions(+), 23 deletions(-)
--
2.13.0
7 years, 4 months
[libvirt] [PATCH] cpu_ppc64: Add support for host-model on POWER9
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/cpu/cpu_ppc64.c | 8 ++++----
.../qemuxml2argv-pseries-cpu-compat-power9.args | 24 ++++++++++++++++++++++
.../qemuxml2argv-pseries-cpu-compat-power9.xml | 21 +++++++++++++++++++
tests/qemuxml2argvtest.c | 7 +++++++
tests/testutilsqemu.c | 13 +++++++++++-
tests/testutilsqemu.h | 1 +
6 files changed, 69 insertions(+), 5 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index f64592b55..bf0859904 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -92,22 +92,22 @@ ppc64CheckCompatibilityMode(const char *host_model,
if (!compat_mode)
return VIR_CPU_COMPARE_IDENTICAL;
- /* Valid host CPUs: POWER6, POWER7, POWER8 */
+ /* Valid host CPUs: POWER6, POWER7, POWER8, POWER9 */
if (!STRPREFIX(host_model, "POWER") ||
!(tmp = (char *) host_model + strlen("POWER")) ||
virStrToLong_i(tmp, NULL, 10, &host) < 0 ||
- host < 6 || host > 8) {
+ host < 6 || host > 9) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s",
_("Host CPU does not support compatibility modes"));
goto out;
}
- /* Valid compatibility modes: power6, power7, power8 */
+ /* Valid compatibility modes: power6, power7, power8, power9 */
if (!STRPREFIX(compat_mode, "power") ||
!(tmp = (char *) compat_mode + strlen("power")) ||
virStrToLong_i(tmp, NULL, 10, &compat) < 0 ||
- compat < 6 || compat > 8) {
+ compat < 6 || compat > 9) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown compatibility mode %s"),
compat_mode);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
new file mode 100644
index 000000000..af93d63dc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-S \
+-M pseries \
+-cpu host,compat=power9 \
+-m 256 \
+-smp 4,sockets=4,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-boot c \
+-usb \
+-chardev pty,id=charserial0 \
+-device spapr-vty,chardev=charserial0,reg=0x30000000
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
new file mode 100644
index 000000000..30ab5c267
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
@@ -0,0 +1,21 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>4</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <cpu mode='host-model'>
+ <model>power9</model>
+ </cpu>
+ <clock offset='utc'/>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <console type='pty'>
+ <address type="spapr-vio"/>
+ </console>
+ <memballoon model="none"/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 426959857..669caa0e4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1673,6 +1673,13 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST_FAILURE("pseries-cpu-compat-power9", QEMU_CAPS_KVM);
+
+ qemuTestSetHostCPU(driver.caps, cpuPower9);
+ DO_TEST("pseries-cpu-compat-power9",
+ QEMU_CAPS_KVM, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+ qemuTestSetHostCPU(driver.caps, NULL);
+
qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
DO_TEST("pseries-panic-missing",
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 709e291bd..ee4853841 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -17,6 +17,7 @@
virCPUDefPtr cpuDefault;
virCPUDefPtr cpuHaswell;
virCPUDefPtr cpuPower8;
+virCPUDefPtr cpuPower9;
static virCPUFeatureDef cpuDefaultFeatures[] = {
{ (char *) "ds", -1 },
@@ -94,6 +95,15 @@ static virCPUDef cpuPower8Data = {
.threads = 8,
};
+static virCPUDef cpuPower9Data = {
+ .type = VIR_CPU_TYPE_HOST,
+ .arch = VIR_ARCH_PPC64,
+ .model = (char *) "POWER9",
+ .sockets = 1,
+ .cores = 16,
+ .threads = 1,
+};
+
typedef enum {
TEST_UTILS_QEMU_BIN_I686,
TEST_UTILS_QEMU_BIN_X86_64,
@@ -467,7 +477,8 @@ virCapsPtr testQemuCapsInit(void)
if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
!(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) ||
- !(cpuPower8 = virCPUDefCopy(&cpuPower8Data)))
+ !(cpuPower8 = virCPUDefCopy(&cpuPower8Data)) ||
+ !(cpuPower9 = virCPUDefCopy(&cpuPower9Data)))
goto cleanup;
qemuTestSetHostCPU(caps, NULL);
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 3393f5eb7..05e5651ae 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -21,6 +21,7 @@ virQEMUCapsPtr qemuTestParseCapabilities(virCapsPtr caps,
extern virCPUDefPtr cpuDefault;
extern virCPUDefPtr cpuHaswell;
extern virCPUDefPtr cpuPower8;
+extern virCPUDefPtr cpuPower9;
void qemuTestSetHostArch(virCapsPtr caps,
virArch arch);
--
2.13.0
7 years, 4 months
[libvirt] [PATCH] qemuDomainBlockCopyCommon: Fix the memory leak
by Jie Wang
When take the cleanup branch, will leads to the mirror memory leak
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1e3c7fc..74cc2c4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16856,7 +16856,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
endjob:
if (need_unlink && unlink(mirror->path))
VIR_WARN("unable to unlink just-created %s", mirror->path);
- virStorageSourceFree(mirror);
qemuDomainObjEndJob(driver, vm);
if (monitor_error) {
virSetError(monitor_error);
@@ -16866,6 +16865,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
cleanup:
VIR_FREE(device);
virObjectUnref(cfg);
+ virStorageSourceFree(mirror);
return ret;
}
--
1.8.3.1
7 years, 4 months