[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, 5 months
[libvirt] CFP: KVM Forum 2017
by Paolo Bonzini
================================================================
KVM Forum 2017: Call For Participation
October 25-27, 2017 - Hilton Prague - Prague, Czech Republic
(All submissions must be received before midnight June 15, 2017)
=================================================================
KVM Forum is an annual event that presents a rare opportunity
for developers and users to meet, discuss the state of Linux
virtualization technology, and plan for the challenges ahead.
We invite you to lead part of the discussion by submitting a speaking
proposal for KVM Forum 2017.
At this highly technical conference, developers driving innovation
in the KVM virtualization stack (Linux, KVM, QEMU, libvirt) can
meet users who depend on KVM as part of their offerings, or to
power their data centers and clouds.
KVM Forum will include sessions on the state of the KVM
virtualization stack, planning for the future, and many
opportunities for attendees to collaborate. As we celebrate ten years
of KVM development in the Linux kernel, KVM continues to be a
critical part of the FOSS cloud infrastructure.
This year, KVM Forum is joining Open Source Summit in Prague,
Czech Republic. Selected talks from KVM Forum will be presented on
Wednesday October 25 to the full audience of the Open Source Summit.
Also, attendees of KVM Forum will have access to all of the talks from
Open Source Summit on Wednesday.
http://events.linuxfoundation.org/cfp
Suggested topics:
* Scaling, latency optimizations, performance tuning, real-time guests
* Hardening and security
* New features
* Testing
KVM and the Linux kernel:
* Nested virtualization
* Resource management (CPU, I/O, memory) and scheduling
* VFIO: IOMMU, SR-IOV, virtual GPU, etc.
* Networking: Open vSwitch, XDP, etc.
* virtio and vhost
* Architecture ports and new processor features
QEMU:
* Management interfaces: QOM and QMP
* New devices, new boards, new architectures
* Graphics, desktop virtualization and virtual GPU
* New storage features
* High availability, live migration and fault tolerance
* Emulation and TCG
* Firmware: ACPI, UEFI, coreboot, U-Boot, etc.
Management and infrastructure
* Managing KVM: Libvirt, OpenStack, oVirt, etc.
* Storage: Ceph, Gluster, SPDK, etc.r
* Network Function Virtualization: DPDK, OPNFV, OVN, etc.
* Provisioning
===============
SUBMITTING YOUR PROPOSAL
===============
Abstracts due: June 15, 2017
Please submit a short abstract (~150 words) describing your presentation
proposal. Slots vary in length up to 45 minutes. Also include the proposal
type -- one of:
- technical talk
- end-user talk
Submit your proposal here:
http://events.linuxfoundation.org/cfp
Please only use the categories "presentation" and "panel discussion"
You will receive a notification whether or not your presentation proposal
was accepted by August 10, 2017.
Speakers will receive a complimentary pass for the event. In the instance
that case your submission has multiple presenters, only the primary speaker for a
proposal will receive a complimentary event pass. For panel discussions, all
panelists will receive a complimentary event pass.
TECHNICAL TALKS
A good technical talk should not just report on what has happened over
the last year; it should present a concrete problem and how it impacts
the user and/or developer community. Whenever applicable, focus on
work that needs to be done, difficulties that haven't yet been solved,
and on decisions that other developers should be aware of. Summarizing
recent developments is okay but it should not be more than a small
portion of the overall talk.
END-USER TALKS
One of the big challenges as developers is to know what, where and how
people actually use our software. We will reserve a few slots for end
users talking about their deployment challenges and achievements.
If you are using KVM in production you are encouraged submit a speaking
proposal. Simply mark it as an end-user talk. As an end user, this is a
unique opportunity to get your input to developers.
HANDS-ON / BOF SESSIONS
We will reserve some time for people to get together and discuss
strategic decisions as well as other topics that are best solved within
smaller groups.
These sessions will be announced during the event. If you are interested
in organizing such a session, please add it to the list at
http://www.linux-kvm.org/page/KVM_Forum_2017_BOF
Let people you think who might be interested know about your BOF, and encourage
them to add their names to the wiki page as well. Please try to
add your ideas to the list before KVM Forum starts.
PANEL DISCUSSIONS
If you are proposing a panel discussion, please make sure that you list
all of your potential panelists in your the abstract. We will request full
biographies if a panel is accepted.
===============
HOTEL / TRAVEL
===============
This year's event will take place at the Hilton Prague.
For information on discounted room rates for conference attendees
and on other hotels close to the conference, please visit
http://events.linuxfoundation.org/events/kvm-forum/attend/hotel-travel.
===============
IMPORTANT DATES
===============
Submission deadline: June 15, 2017
Notification: August 10, 2017
Schedule announced: August 17, 2017
Event dates: October 25-27, 2017
Thank you for your interest in KVM. We're looking forward to your
submissions and seeing you at the KVM Forum 2017 in October!
-your KVM Forum 2017 Program Committee
Please contact us with any questions or comments at
kvm-forum-2017-pc(a)redhat.com
7 years, 5 months
[libvirt] Remotable Libvirt
by Peter
Hi Everyone,
We are working towards building on the virtualization management
functionality in cockpit (http://cockpit-project.org/) and wanted to get
some feedback on the best way to integrate with libvirt.
As a quick overview, cockpit aims to talk to existing remotable system
APIs. Usually these API’s take the form of dbus, REST or executable
commands. The majority of cockpit is implemented in javascript. There is
no cockpit backend that knows how to change a hostname for example. The
cockpit backend knows how to handle a dbus payload. The javascript
running in the users browser knows how to use the systemd dbus API at
org.freedesktop.hostname1 to manage the system hostname.
Right now some of the basics have been implemented by spawning commands
on the system. This isn't ideal because it involves parsing / screen
scraping output and doesn't support receiving events so we have to poll
(ei run the command again) to keep the UI up to date.
As far as I know libvirt doesn't currently have a remoteable API. It
does have a daemon that communicates with clients via a XDR RPC.
(https://libvirt.org/internals/rpc.html) However from what I'm hearing
the RPC is considered an internal implementation and shouldn't be used
by external applications. Is that still the case? Is there any chance of
getting talking the daemon directly using the XDR standard for a subset
of methods blessed as part of the externally supported API?
An alternative is to implement a standards based remotable API, using
something like dbus or REST, that can be used by external applications.
I imagine that this would be at a bit of a higher level than the current
RPC and contain at least some of the logic around the actions it
performs rather than being a direct passthrough to the daemon.
Of course that is a pretty big undertaking and would, in my opinion,
only be worth it if there is broader interest in the community and use
cases beyond what cockpit would like to.
7 years, 5 months
[libvirt] [PATCH] lxc: allow defining environment variables
by Cédric Bosdonnat
When running an application container, setting environment variables
could be important.
The newly introduced <initenv> tag in domain configuration will allow
setting environment variables to the init program.
---
docs/formatdomain.html.in | 5 +++++
docs/schemas/domaincommon.rng | 10 ++++++++++
src/conf/domain_conf.c | 38 ++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 8 ++++++++
src/lxc/lxc_container.c | 5 +++++
tests/lxcxml2xmldata/lxc-initenv.xml | 30 ++++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
7 files changed, 97 insertions(+)
create mode 100644 tests/lxcxml2xmldata/lxc-initenv.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 07208eef8..8da50875b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -326,6 +326,10 @@
element, if set will be used to provide an equivalent to <code>/proc/cmdline</code>
but will not affect init argv.
</p>
+ <p>
+ To set environment variables, use the <code>initenv</code> element, one
+ for each variable.
+ </p>
<pre>
<os>
@@ -333,6 +337,7 @@
<init>/bin/systemd</init>
<initarg>--unit</initarg>
<initarg>emergency.service</initarg>
+ <initenv name='MYENV'>some value</initenv>
</os>
</pre>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4d9f8d1a2..695214816 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -385,6 +385,16 @@
<text/>
</element>
</zeroOrMore>
+ <zeroOrMore>
+ <element name="initenv">
+ <attribute name="name">
+ <data type='string'>
+ <param name='pattern'>[a-zA-Z_]+[a-zA-Z0-9_]*</param>
+ </data>
+ </attribute>
+ <text/>
+ </element>
+ </zeroOrMore>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c7e20b8ba..89c803047 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2799,6 +2799,9 @@ void virDomainDefFree(virDomainDefPtr def)
for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
VIR_FREE(def->os.initargv[i]);
VIR_FREE(def->os.initargv);
+ for (i = 0; def->os.initenv && def->os.initenv[i]; i++)
+ VIR_FREE(def->os.initenv[i]);
+ VIR_FREE(def->os.initenv);
VIR_FREE(def->os.kernel);
VIR_FREE(def->os.initrd);
VIR_FREE(def->os.cmdline);
@@ -16776,6 +16779,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
xmlNodePtr *nodes = NULL;
xmlNodePtr oldnode;
char *tmp = NULL;
+ char *name = NULL;
int ret = -1;
size_t i;
int n;
@@ -16811,6 +16815,37 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
+
+ if ((n = virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0)
+ goto error;
+
+ if (VIR_ALLOC_N(def->os.initenv, n+1) < 0)
+ goto error;
+ for (i = 0; i < n; i++) {
+ if (!(name = virXMLPropString(nodes[i], "name"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("No name supplied for <initenv> element"));
+ goto error;
+ }
+
+ if (!nodes[i]->children ||
+ !nodes[i]->children->content) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("No value supplied for <initenv name='%s'> element"),
+ name);
+ goto error;
+ }
+
+ if (VIR_ALLOC(def->os.initenv[i]) < 0)
+ goto error;
+
+ def->os.initenv[i]->name = name;
+ if (VIR_STRDUP(def->os.initenv[i]->value,
+ (const char*) nodes[i]->children->content) < 0)
+ goto error;
+ }
+ def->os.initenv[n] = NULL;
+ VIR_FREE(nodes);
}
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
@@ -24524,6 +24559,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
virBufferEscapeString(buf, "<initarg>%s</initarg>\n",
def->os.initargv[i]);
+ for (i = 0; def->os.initenv && def->os.initenv[i]; i++)
+ virBufferAsprintf(buf, "<initenv name='%s'>%s</initenv>\n",
+ def->os.initenv[i]->name, def->os.initenv[i]->value);
if (def->os.loader)
virDomainLoaderDefFormat(buf, def->os.loader);
virBufferEscapeString(buf, "<kernel>%s</kernel>\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 83e067269..03153b972 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1820,6 +1820,13 @@ typedef enum {
VIR_ENUM_DECL(virDomainIOAPIC);
/* Operating system configuration data & machine / arch */
+typedef struct _virDomainOSEnv virDomainOSEnv;
+typedef virDomainOSEnv *virDomainOSEnvPtr;
+struct _virDomainOSEnv {
+ char *name;
+ char *value;
+};
+
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
@@ -1833,6 +1840,7 @@ struct _virDomainOSDef {
bool bm_timeout_set;
char *init;
char **initargv;
+ virDomainOSEnvPtr *initenv;
char *kernel;
char *initrd;
char *cmdline;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index af02b5460..ffafc39d7 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -246,6 +246,11 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
if (vmDef->os.cmdline)
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_CMDLINE", vmDef->os.cmdline);
+ for (i = 0; vmDef->os.initenv[i]; i++) {
+ virCommandAddEnvPair(cmd, vmDef->os.initenv[i]->name,
+ vmDef->os.initenv[i]->value);
+ }
+
virBufferFreeAndReset(&buf);
return cmd;
}
diff --git a/tests/lxcxml2xmldata/lxc-initenv.xml b/tests/lxcxml2xmldata/lxc-initenv.xml
new file mode 100644
index 000000000..933d836a2
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-initenv.xml
@@ -0,0 +1,30 @@
+<domain type='lxc'>
+ <name>jessie</name>
+ <uuid>e21987a5-e98e-9c99-0e35-803e4d9ad1fe</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <resource>
+ <partition>/machine</partition>
+ </resource>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/sbin/sh</init>
+ <initenv name='FOO'>bar</initenv>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='mount' accessmode='passthrough'>
+ <source dir='/mach/jessie'/>
+ <target dir='/'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+ <seclabel type='none'/>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 226a73d27..2a24b60b3 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -98,6 +98,7 @@ mymain(void)
DO_TEST("ethernet-hostip");
DO_TEST_FULL("filesystem-root", 0, false,
VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS);
+ DO_TEST("initenv");
virObjectUnref(caps);
virObjectUnref(xmlopt);
--
2.12.2
7 years, 5 months
[libvirt] [PATCH] audit: Fix the output message for shmem
by Martin Kletzander
After some discussion on and off the linux-audit mailing list, we
should use different fields for the audit messages.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_audit.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 2d9ff5e3ffea..1e667af73c4f 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -983,15 +983,13 @@ virDomainAuditShmem(virDomainObjPtr vm,
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = virAuditEncode("vm", vm->def->name);
const char *srcpath = virDomainAuditChardevPath(&def->server.chr);
- char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath));
- char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name));
const char *virt = virDomainVirtTypeToString(vm->def->virtType);
- char *size = NULL;
+ char *shmpath = NULL;
virUUIDFormat(vm->def->uuid, uuidstr);
- if (!vmname || !src || !shmem ||
- virAsprintfQuiet(&size, "%llu", def->size) < 0) {
+ if (!vmname ||
+ virAsprintfQuiet(&shmpath, "/dev/shm/%s", def->name) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
@@ -1002,14 +1000,18 @@ virDomainAuditShmem(virDomainObjPtr vm,
virt = "?";
}
- VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
- "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s",
- virt, reason, vmname, uuidstr, size, shmem, src);
+ if (def->server.enabled) {
+ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
+ "virt=%s resrc=ivshmem-socket reason=%s %s uuid=%s path=%s",
+ virt, reason, vmname, uuidstr, VIR_AUDIT_STR(srcpath));
+ } else {
+ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
+ "virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
+ virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
+ }
cleanup:
VIR_FREE(vmname);
- VIR_FREE(src);
- VIR_FREE(size);
- VIR_FREE(shmem);
+ VIR_FREE(shmpath);
return;
}
--
2.13.0
7 years, 5 months
[libvirt] [V4 RESEND PATCH] Expose resource control capabilites on cache bank
by taget
From: Eli Qiao <liyong.qiao(a)intel.com>
* This patch amends the cache bank capability as follow:
<cache>
<bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
<control min='768' unit='KiB' scope='both' max_allocation='4'/>
</bank>
<bank id='1' level='3' type='unified' size='15360' unit='KiB' cpus='6-11'>
<control min='768' unit='KiB' scope='both' max_allocation='4'/>
</bank>
</cache>
For CDP enabled on x86 arch, we will have:
<cache>
<bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
<control min='768' unit='KiB' scope='code' max_allocation='4'/>
<control min='768' unit='KiB' scope='data' max_allocation='4'/>
</bank>
...
* Added a new testdata directory `linux-resctrl-cdp` to test CDP enabled
case.
* Along with vircaps2xmltest case updated.
P.S. here the scope is from /sys/fs/resctrl/info/L3{"" "code" "data"}, I
keep it capital upper as I need to use a macro to convert from enum to
string easily.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
docs/schemas/capability.rng | 20 ++++
src/conf/capabilities.c | 133 ++++++++++++++++++++-
src/conf/capabilities.h | 10 ++
.../vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus | 1 +
.../linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask | 1 +
.../resctrl/info/L3CODE/min_cbm_bits | 1 +
.../resctrl/info/L3CODE/num_closids | 1 +
.../linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask | 1 +
.../resctrl/info/L3DATA/min_cbm_bits | 1 +
.../resctrl/info/L3DATA/num_closids | 1 +
.../linux-resctrl-cdp/resctrl/manualres/cpus | 1 +
.../linux-resctrl-cdp/resctrl/manualres/schemata | 2 +
.../linux-resctrl-cdp/resctrl/manualres/tasks | 0
.../linux-resctrl-cdp/resctrl/schemata | 2 +
.../linux-resctrl-cdp/resctrl/tasks | 0
tests/vircaps2xmldata/linux-resctrl-cdp/system | 1 +
.../vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml | 55 +++++++++
tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 8 +-
tests/vircaps2xmltest.c | 8 ++
19 files changed, 244 insertions(+), 3 deletions(-)
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
create mode 120000 tests/vircaps2xmldata/linux-resctrl-cdp/system
create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 26f0aa2..927fc18 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -277,6 +277,26 @@
<attribute name='cpus'>
<ref name='cpuset'/>
</attribute>
+ <zeroOrMore>
+ <element name='control'>
+ <attribute name='min'>
+ <ref name='unsignedInt'/>
+ </attribute>
+ <attribute name='unit'>
+ <ref name='unit'/>
+ </attribute>
+ <attribute name='scope'>
+ <choice>
+ <value>both</value>
+ <value>code</value>
+ <value>data</value>
+ </choice>
+ </attribute>
+ <attribute name='max_allocation'>
+ <ref name='unsignedInt'/>
+ </attribute>
+ </element>
+ </zeroOrMore>
</element>
</oneOrMore>
</element>
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index d699b08..c4a1fdf 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -51,6 +51,7 @@
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
#define SYSFS_SYSTEM_PATH "/sys/devices/system"
+#define SYSFS_RESCTRL_PATH "/sys/fs/resctrl"
VIR_LOG_INIT("conf.capabilities")
@@ -872,6 +873,9 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
virCapsHostCacheBankPtr *caches)
{
size_t i = 0;
+ size_t j = 0;
+ int indent = virBufferGetIndent(buf, false);
+ virBuffer controlBuf = VIR_BUFFER_INITIALIZER;
if (!ncaches)
return 0;
@@ -893,13 +897,35 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
*/
virBufferAsprintf(buf,
"<bank id='%u' level='%u' type='%s' "
- "size='%llu' unit='%s' cpus='%s'/>\n",
+ "size='%llu' unit='%s' cpus='%s'",
bank->id, bank->level,
virCacheTypeToString(bank->type),
bank->size >> (kilos * 10),
kilos ? "KiB" : "B",
cpus_str);
+ virBufferAdjustIndent(&controlBuf, indent + 4);
+ for (j = 0; j < bank->ncontrols; j++) {
+ bool min_kilos = !(bank->controls[j]->min % 1024);
+ virBufferAsprintf(&controlBuf,
+ "<control min='%llu' unit='%s' "
+ "scope='%s' max_allocation='%u'/>\n",
+ bank->controls[j]->min >> (min_kilos * 10),
+ min_kilos ? "KiB" : "B",
+ virCacheTypeToString(bank->controls[j]->scope),
+ bank->controls[j]->max_allocation);
+ }
+
+ if (virBufferUse(&controlBuf)) {
+ virBufferAddLit(buf, ">\n");
+ virBufferAddBuffer(buf, &controlBuf);
+ virBufferAddLit(buf, "</bank>\n");
+
+ } else {
+ virBufferAddLit(buf, "/>\n");
+ }
+
+ virBufferFreeAndReset(&controlBuf);
VIR_FREE(cpus_str);
}
@@ -1519,13 +1545,102 @@ virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a,
void
virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr)
{
+ size_t i;
+
if (!ptr)
return;
virBitmapFree(ptr->cpus);
+ for (i = 0; i < ptr->ncontrols; i++)
+ VIR_FREE(ptr->controls[i]);
+ VIR_FREE(ptr->controls);
VIR_FREE(ptr);
}
+/* test which TYPE of cache control supported
+ * -1: don't support
+ * 0: cat
+ * 1: cdp
+ */
+static int
+virCapabilitiesGetCacheControlType(virCapsHostCacheBankPtr bank)
+{
+ int ret = -1;
+ char *path = NULL;
+ if (virAsprintf(&path,
+ SYSFS_RESCTRL_PATH "/info/L%u",
+ bank->level) < 0)
+ return -1;
+
+ if (virFileExists(path)) {
+ ret = 0;
+ } else {
+ VIR_FREE(path);
+ /* for CDP enabled case, CODE and DATA will show together */
+ if (virAsprintf(&path,
+ SYSFS_RESCTRL_PATH "/info/L%uCODE",
+ bank->level) < 0)
+ return -1;
+ if (virFileExists(path))
+ ret = 1;
+ }
+
+ VIR_FREE(path);
+ return ret;
+}
+
+static int
+virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
+ virCacheType scope)
+{
+ int ret = -1;
+ char *path = NULL;
+ char *cbm_mask = NULL;
+ char *type_upper = NULL;
+ virCapsHostCacheControlPtr control;
+
+ if (VIR_ALLOC(control) < 0)
+ goto cleanup;
+
+ if ((scope > VIR_CACHE_TYPE_BOTH)
+ && (virStringToUpper(&type_upper, virCacheTypeToString(scope)) < 0))
+ goto cleanup;
+
+ if (virFileReadValueUint(&control->max_allocation,
+ SYSFS_RESCTRL_PATH "/info/L%u%s/num_closids",
+ bank->level,
+ type_upper ? type_upper : "") < 0)
+ goto cleanup;
+
+ if (virFileReadValueString(&cbm_mask,
+ SYSFS_RESCTRL_PATH
+ "/info/L%u%s/cbm_mask",
+ bank->level,
+ type_upper ? type_upper: "") < 0)
+ goto cleanup;
+
+ virStringTrimOptionalNewline(cbm_mask);
+
+ /* cbm_mask: cache bit mask, it's in hex, eg: fffff */
+ control->min = bank->size / (strlen(cbm_mask) * 4);
+
+ control->scope = scope;
+
+ if (VIR_APPEND_ELEMENT(bank->controls,
+ bank->ncontrols,
+ control) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(path);
+ VIR_FREE(cbm_mask);
+ VIR_FREE(type_upper);
+ VIR_FREE(control);
+ return ret;
+}
+
int
virCapabilitiesInitCaches(virCapsPtr caps)
{
@@ -1534,6 +1649,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
ssize_t pos = -1;
DIR *dirp = NULL;
int ret = -1;
+ int typeret;
char *path = NULL;
char *type = NULL;
struct dirent *ent = NULL;
@@ -1607,12 +1723,27 @@ virCapabilitiesInitCaches(virCapsPtr caps)
SYSFS_SYSTEM_PATH, pos, ent->d_name) < 0)
goto cleanup;
+ typeret = virCapabilitiesGetCacheControlType(bank);
+
+ if (typeret == 0) {
+ if (virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_BOTH) < 0)
+ goto cleanup;
+ } else if (typeret == 1) {
+ if ((virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_CODE) < 0) ||
+ (virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_DATA) < 0))
+ goto cleanup;
+ }
+
kernel_type = virCacheKernelTypeFromString(type);
if (kernel_type < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown cache type '%s'"), type);
goto cleanup;
}
+
bank->type = kernel_type;
VIR_FREE(type);
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index a8cccf7..ee87d59 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -148,6 +148,14 @@ typedef enum {
VIR_ENUM_DECL(virCache);
+typedef struct _virCapsHostCacheControl virCapsHostCacheControl;
+typedef virCapsHostCacheControl *virCapsHostCacheControlPtr;
+struct _virCapsHostCacheControl {
+ unsigned long long min; /* minimum cache control size in B */
+ virCacheType scope; /* data, code or both */
+ unsigned int max_allocation; /* max number of supported allocations */
+};
+
typedef struct _virCapsHostCacheBank virCapsHostCacheBank;
typedef virCapsHostCacheBank *virCapsHostCacheBankPtr;
struct _virCapsHostCacheBank {
@@ -156,6 +164,8 @@ struct _virCapsHostCacheBank {
unsigned long long size; /* B */
virCacheType type; /* Data, Instruction or Unified */
virBitmapPtr cpus; /* All CPUs that share this bank */
+ size_t ncontrols;
+ virCapsHostCacheControlPtr *controls;
};
typedef struct _virCapsHost virCapsHost;
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
new file mode 100644
index 0000000..b3a79aa
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
@@ -0,0 +1 @@
+ffffff,ffffffff,ffffffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
new file mode 100755
index 0000000..78031da
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
@@ -0,0 +1 @@
+fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
new file mode 100755
index 0000000..d00491f
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
new file mode 100755
index 0000000..45a4fb7
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
@@ -0,0 +1 @@
+8
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
new file mode 100755
index 0000000..78031da
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
@@ -0,0 +1 @@
+fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
new file mode 100755
index 0000000..d00491f
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
new file mode 100755
index 0000000..45a4fb7
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
@@ -0,0 +1 @@
+8
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
new file mode 100644
index 0000000..ede4cc2
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
@@ -0,0 +1 @@
+000000,00000000,00000000
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
new file mode 100644
index 0000000..a0ef381
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
@@ -0,0 +1,2 @@
+L3DATA:0=c0000;1=c0000
+L3CODE:0=30000;1=30000
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks
new file mode 100644
index 0000000..e69de29
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
new file mode 100644
index 0000000..89dc76b
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
@@ -0,0 +1,2 @@
+L3DATA:0=fffff;1=fffff
+L3CODE:0=fffff;1=fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
new file mode 100644
index 0000000..e69de29
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/system b/tests/vircaps2xmldata/linux-resctrl-cdp/system
new file mode 120000
index 0000000..2f3a1d9
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/system
@@ -0,0 +1 @@
+../linux-resctrl/system/
\ No newline at end of file
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
new file mode 100644
index 0000000..c9f460d
--- /dev/null
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
@@ -0,0 +1,55 @@
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>x86_64</arch>
+ </cpu>
+ <power_management/>
+ <migration_features>
+ <live/>
+ </migration_features>
+ <topology>
+ <cells num='2'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='6'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
+ <cpu id='1' socket_id='0' core_id='1' siblings='1'/>
+ <cpu id='2' socket_id='0' core_id='2' siblings='2'/>
+ <cpu id='3' socket_id='0' core_id='3' siblings='3'/>
+ <cpu id='4' socket_id='0' core_id='4' siblings='4'/>
+ <cpu id='5' socket_id='0' core_id='5' siblings='5'/>
+ </cpus>
+ </cell>
+ <cell id='1'>
+ <memory unit='KiB'>2097152</memory>
+ <pages unit='KiB' size='4'>4096</pages>
+ <pages unit='KiB' size='2048'>6144</pages>
+ <pages unit='KiB' size='1048576'>8192</pages>
+ <cpus num='6'>
+ <cpu id='6' socket_id='1' core_id='0' siblings='6'/>
+ <cpu id='7' socket_id='1' core_id='1' siblings='7'/>
+ <cpu id='8' socket_id='1' core_id='2' siblings='8'/>
+ <cpu id='9' socket_id='1' core_id='3' siblings='9'/>
+ <cpu id='10' socket_id='1' core_id='4' siblings='10'/>
+ <cpu id='11' socket_id='1' core_id='5' siblings='11'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ <cache>
+ <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
+ <control min='768' unit='KiB' scope='code' max_allocation='8'/>
+ <control min='768' unit='KiB' scope='data' max_allocation='8'/>
+ </bank>
+ <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
+ <control min='768' unit='KiB' scope='code' max_allocation='8'/>
+ <control min='768' unit='KiB' scope='data' max_allocation='8'/>
+ </bank>
+ </cache>
+ </host>
+
+</capabilities>
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
index 6677791..04a5eb8 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
@@ -41,8 +41,12 @@
</cells>
</topology>
<cache>
- <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'/>
- <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'/>
+ <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
+ <control min='768' unit='KiB' scope='both' max_allocation='4'/>
+ </bank>
+ <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
+ <control min='768' unit='KiB' scope='both' max_allocation='4'/>
+ </bank>
</cache>
</host>
diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
index 137598e..ae1cd52 100644
--- a/tests/vircaps2xmltest.c
+++ b/tests/vircaps2xmltest.c
@@ -47,6 +47,7 @@ test_virCapabilities(const void *opaque)
char *capsXML = NULL;
char *path = NULL;
char *dir = NULL;
+ char *resctrl = NULL;
int ret = -1;
/*
@@ -58,7 +59,12 @@ test_virCapabilities(const void *opaque)
data->resctrl ? "/system" : "") < 0)
goto cleanup;
+ if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl",
+ abs_srcdir, data->filename) < 0)
+ goto cleanup;
+
virFileWrapperAddPrefix("/sys/devices/system", dir);
+ virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
if (!caps)
@@ -84,6 +90,7 @@ test_virCapabilities(const void *opaque)
cleanup:
VIR_FREE(dir);
+ VIR_FREE(resctrl);
VIR_FREE(path);
VIR_FREE(capsXML);
virObjectUnref(caps);
@@ -112,6 +119,7 @@ mymain(void)
DO_TEST("caches", VIR_ARCH_X86_64);
DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true);
+ DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true);
return ret;
}
--
1.9.1
7 years, 5 months
[libvirt] [PATCH v2] virsh: add [--domain DOMAIN] option to domxml-to-native DOMAIN COMMAND
by Daniel Liu
The option allows someone to run domain-to-native on already existing
domain without the need of supplying their XML. It is basically
wrapper around 'virsh dumpxml | virsh domxml-to-native /dev/stdin'.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=835476
---
tools/virsh-domain.c | 52 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 12 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index ccb514ef9..929f9c896 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9848,9 +9848,13 @@ static const vshCmdOptDef opts_domxmltonative[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("target config data type format")
},
+ {.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ_OPT,
+ .help = N_("domain name, id or uuid")
+ },
{.name = "xml",
.type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
.help = N_("xml data file to export from")
},
{.name = NULL}
@@ -9859,30 +9863,54 @@ static const vshCmdOptDef opts_domxmltonative[] = {
static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- bool ret = true;
+ bool ret = false;
const char *format = NULL;
- const char *xmlFile = NULL;
- char *configData;
- char *xmlData;
+ const char *domain = NULL;
+ const char *xml = NULL;
+ char *xmlData = NULL;
+ char *configData = NULL;
unsigned int flags = 0;
virshControlPtr priv = ctl->privData;
+ virDomainPtr dom = NULL;
if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
+ vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "domain", &domain) < 0)
return false;
- if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0)
+ VSH_EXCLUSIVE_OPTIONS_VAR(domain, xml);
+
+ if (domain) {
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+ }
+
+ if (dom) {
+ xmlData = virDomainGetXMLDesc(dom, flags);
+ } else if (xml) {
+ if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlData) < 0)
+ goto cleanup;
+ }
+
+ if (!xmlData) {
+ vshError(ctl, "%s",
+ _("need either domain (ID, UUID, or name) or domain XML configuration file path"));
return false;
+ }
- configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags);
- if (configData != NULL) {
- vshPrint(ctl, "%s", configData);
- VIR_FREE(configData);
+ if (!(configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags))) {
+ vshError(ctl, "%s",
+ _("convert from domain XML to native command failed"));
+ goto cleanup;
} else {
- ret = false;
+ vshPrint(ctl, "%s", configData);
+ ret = true;
}
+ cleanup:
+ virshDomainFree(dom);
VIR_FREE(xmlData);
+ VIR_FREE(configData);
return ret;
}
--
2.13.0
7 years, 5 months
[libvirt] [PATCH v2 00/14] Work towards making virNodeDeviceObjPtr private
by John Ferlan
v1: https://www.redhat.com/archives/libvir-list/2017-May/msg00718.html
Changes since v1:
* Adjusted the title of cover letter to more appropriately match what's
being done.
* Added new patch 3 to cover issues I've noted in recent code reviews
where additions to virNodeDevCapType may not be properly 'covered'
in the virNodeDeviceObjHasCap and virNodeDeviceCapMatch helpers. With
the switch, it'll be forced.
* Removed former patch 4 - I'll deal with it later.
* Added patch 13
* Patch 14 is the old patch 13o
There's another 8 or so patches waiting to go, but the "next" one in the
series depends on other things currently on list waiting for review.
John Ferlan (14):
test: Adjust cleanup/error paths for nodedev test APIs
nodedev: Fix locking in virNodeDeviceObjRemove
nodedev: Need to check for vport capable scsi_host for vHBA searches
nodedev: Use switch for virNodeDeviceObjHasCap and
virNodeDeviceCapMatch
nodedev: Use common naming for virnodedeviceobj
nodedev: Cleanup driver code and prototypes
nodedev: Alter param to nodeDeviceUpdateDriverName
nodedev: Alter param to nodeDeviceUpdateCaps
nodedev: Create helper for finding by name in driver
nodedev: Use consistent names for driver variables
nodedev: Introduce virNodeDeviceObjGetDef
nodedev: Remove privateData from virNodeDeviceObj
nodedev: Pass @def by reference to create/assign object
nodedev: Introduce virNodeDeviceObjNew
src/conf/node_device_conf.h | 2 -
src/conf/virnodedeviceobj.c | 252 ++++++++++++++++-----------
src/conf/virnodedeviceobj.h | 4 +-
src/libvirt_private.syms | 1 +
src/node_device/node_device_driver.c | 233 ++++++++++++-------------
src/node_device/node_device_driver.h | 93 +++++++---
src/node_device/node_device_hal.c | 56 +++---
src/node_device/node_device_udev.c | 321 ++++++++++++++++++++---------------
src/test/test_driver.c | 118 +++++++------
9 files changed, 609 insertions(+), 471 deletions(-)
--
2.9.4
7 years, 5 months
[libvirt] [PATCH v3 0/9] Multiple cleanups within interfaceobj and interface driver
by John Ferlan
v2: https://www.redhat.com/archives/libvir-list/2017-May/msg01059.html
v1: https://www.redhat.com/archives/libvir-list/2017-April/msg01225.html
Patches 1-7 were acked in v1 with a request to "show" the next step in
a 9/8 patch to convert to using virObject for virInterfaceObj. v2 added
that, but also added a couple of patches that were unfavorable.
Since I didn't want to push something partial and it was later in the
release cycle, I didn't push 1-7. This series keeps the v1 patch 8 in
tact and adds patch9 which does the virObject conversion and the
virInterfaceObjEndAPI in the same patch (v2 separated those, but it seeems
Peter wasn't favoring that option, so I combined them).
I know this is not 3.4 material, but with a successful review of 8 & 9,
I would push this after 3.4 is cut.
John Ferlan (9):
interface: Consistently use 'obj' for a virInterfaceObjPtr
interface: Remove some unnecessary goto's for Interface tests
interface: Use virInterfaceDefPtr rather than deref from
virInterfaceObjPtr
interface: Make _virInterfaceObj struct private
interface: Make _virInterfaceObjList struct private
interface: Rename some virInterfaceObj* API's
interface: Clean up virInterfaceObjListFindByMACString
interface: Introduce virInterfaceObjNew
interface: Convert virInterfaceObj to use virObjectLockable
po/POTFILES.in | 1 -
src/conf/virinterfaceobj.c | 275 +++++++++++++++++++++++++++++----------------
src/conf/virinterfaceobj.h | 72 ++++++------
src/libvirt_private.syms | 19 ++--
src/test/test_driver.c | 142 ++++++++++++-----------
5 files changed, 292 insertions(+), 217 deletions(-)
--
2.9.4
7 years, 5 months
[libvirt] [PATCH 00/18] Allow virtio devices to use vIOMMU
by Ján Tomko
[Adding Jason to cc - could you please take a look at the documentation
(patches 6 and 8) and point out any device/option combinations that
do not make sense?]
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
Ján Tomko (18):
conf: introduce virDomainControllerDriverFormat
conf: use a separate buffer for the subelements of <controller>
conf: only format <controller> as a pair tag when needed
conf: eliminate monster condition in virDomainControllerDefFormat
virDomainControllerDefFormat: move PCI model and target formatting
conf: add device_iotlb attribute to iommu
qemu: format device-iotlb on intel-iommu command line
qemuxml2xmltest: add virtio-options test
Add virtio-related options to interfaces
add virtio-related options to memballoon
Add virtio-related options to disks
Add virtio-related options to controllers
Add virtio-related options to filesystems
Add virtio-related options to rng devices
Add virtio-related options to video
Add virtio-related options to input devices
qemuxml2argvtest: add virtio-options test case
qemu: format virtio-related options on the command line
docs/formatdomain.html.in | 87 ++++++
docs/schemas/domaincommon.rng | 40 +++
src/conf/domain_conf.c | 314 ++++++++++++++++-----
src/conf/domain_conf.h | 27 ++
src/qemu/qemu_capabilities.c | 15 +-
src/qemu/qemu_capabilities.h | 5 +
src/qemu/qemu_command.c | 69 +++++
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 3 +
.../qemuxml2argv-intel-iommu-device-iotlb.args | 19 ++
.../qemuxml2argv-intel-iommu-device-iotlb.xml | 31 ++
.../qemuxml2argv-virtio-options.args | 57 ++++
.../qemuxml2argv-virtio-options.xml | 104 +++++++
tests/qemuxml2argvtest.c | 18 ++
.../qemuxml2xmlout-intel-iommu-device-iotlb.xml | 1 +
.../qemuxml2xmlout-s390-defaultconsole.xml | 3 +-
.../qemuxml2xmlout-virtio-options.xml | 104 +++++++
tests/qemuxml2xmltest.c | 2 +
17 files changed, 825 insertions(+), 74 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
--
2.10.2
7 years, 5 months