[libvirt] [PATCH] Fix compile error for stable 1.2.9
by Yang hongyang
Seems a backport miss. An extra member is passed to struct
virLXCBasicMountInfo.
Signed-off-by: Yang hongyang <hongyang.yang(a)easystack.cn>
---
src/lxc/lxc_container.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 28dabec..1c65fa9 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -760,7 +760,7 @@ typedef struct {
static const virLXCBasicMountInfo lxcBasicMounts[] = {
{ "proc", "/proc", "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false },
- { "/proc/sys", "/proc/sys", NULL, MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false, false },
+ { "/proc/sys", "/proc/sys", NULL, MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false },
{ "sysfs", "/sys", "sysfs", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false },
{ "securityfs", "/sys/kernel/security", "securityfs", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, true, true },
#if WITH_SELINUX
--
1.7.1
1 year
[libvirt] Supporting vhost-net and macvtap in libvirt for QEMU
by Anthony Liguori
Disclaimer: I am neither an SR-IOV nor a vhost-net expert, but I've CC'd
people that are who can throw tomatoes at me for getting bits wrong :-)
I wanted to start a discussion about supporting vhost-net in libvirt.
vhost-net has not yet been merged into qemu but I expect it will be soon
so it's a good time to start this discussion.
There are two modes worth supporting for vhost-net in libvirt. The
first mode is where vhost-net backs to a tun/tap device. This is
behaves in very much the same way that -net tap behaves in qemu today.
Basically, the difference is that the virtio backend is in the kernel
instead of in qemu so there should be some performance improvement.
Current, libvirt invokes qemu with -net tap,fd=X where X is an already
open fd to a tun/tap device. I suspect that after we merge vhost-net,
libvirt could support vhost-net in this mode by just doing -net
vhost,fd=X. I think the only real question for libvirt is whether to
provide a user visible switch to use vhost or to just always use vhost
when it's available and it makes sense. Personally, I think the later
makes sense.
The more interesting invocation of vhost-net though is one where the
vhost-net device backs directly to a physical network card. In this
mode, vhost should get considerably better performance than the current
implementation. I don't know the syntax yet, but I think it's
reasonable to assume that it will look something like -net
tap,dev=eth0. The effect will be that eth0 is dedicated to the guest.
On most modern systems, there is a small number of network devices so
this model is not all that useful except when dealing with SR-IOV
adapters. In that case, each physical device can be exposed as many
virtual devices (VFs). There are a few restrictions here though. The
biggest is that currently, you can only change the number of VFs by
reloading a kernel module so it's really a parameter that must be set at
startup time.
I think there are a few ways libvirt could support vhost-net in this
second mode. The simplest would be to introduce a new tag similar to
<source network='br0'>. In fact, if you probed the device type for the
network parameter, you could probably do something like <source
network='eth0'> and have it Just Work.
Another model would be to have libvirt see an SR-IOV adapter as a
network pool whereas it handled all of the VF management. Considering
how inflexible SR-IOV is today, I'm not sure whether this is the best model.
Has anyone put any more thought into this problem or how this should be
modeled in libvirt? Michael, could you share your current thinking for
-net syntax?
--
Regards,
Anthony Liguori
1 year
[libvirt] [PATCH v2 0/1] storage: vstorage support
by Olga Krishtal
The patch supports pool and volume managment using Vistuozzo Storage (vstorage)
as a backend.
To define pool use:
virsh -c qemu+unix:///system pool-define-as --name VZ --type vstorage
--source-name vz7-vzstorage --target /vzstorage_pool
The resulting XML:
<pool type='vstorage'>
<name>VZ</name>
<uuid>5f45665b-66fa-4b18-84d1-248774cff3a1</uuid>
<capacity unit='bytes'>107374182400</capacity>
<allocation unit='bytes'>1441144832</allocation>
<available unit='bytes'>105933037568</available>
<source>
<name>vz7-vzstorage</name>
</source>
<target>
<path>/vzstorage_pool</path>
<permissions>
<mode>0700</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</pool>
For the vstorage pool the only obligatory parameter, which stores cluster name,
is --source-name.
v2:
- maximum code reusage
- fixed name issue - we use vstorage
- simplified findPoolSources
Olga Krishtal (1):
storage: vz storage pool support
configure.ac | 28 ++++++++++
docs/schemas/storagepool.rng | 13 +++++
include/libvirt/libvirt-storage.h | 1 +
src/conf/storage_conf.c | 16 +++++-
src/conf/storage_conf.h | 4 +-
src/storage/storage_backend.c | 3 +
src/storage/storage_backend_fs.c | 114 ++++++++++++++++++++++++++++++++++++--
src/storage/storage_backend_fs.h | 3 +
src/storage/storage_driver.c | 2 +
tools/virsh-pool.c | 2 +
tools/virsh.c | 3 +
11 files changed, 181 insertions(+), 8 deletions(-)
--
1.8.3.1
7 years, 11 months
[libvirt] [PATCH 0/2] qemu_cgroup: allow access to /dev/dri/render*
by Ján Tomko
Technically a v2, but v1 is already pushed.
This version is based on the <gl enable> in <spice> instead
of accel3d="yes" in <video><model type="virtio".
It also only allows access to the render* devices, instead of all of them.
https://bugzilla.redhat.com/show_bug.cgi?id=1337290
Ján Tomko (2):
Revert "qemu_cgroup: allow access to /dev/dri for virtio-vga"
qemu_cgroup: allow access to /dev/dri/render*
src/qemu/qemu_cgroup.c | 71 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 14 deletions(-)
--
2.7.3
7 years, 11 months
[libvirt] RFC: add recreate option to domain events conf
by Nikolay Shirokovskiy
Hi, all.
Does it make sense to anybody else that rebooting and resetting
a persistent domain from outside or from inside should bring upon
pending configuration changes? For this purpose we can add another
option to on_reboot and other events, say 'recreate'. From technical
POV qemu has enough capabilities, namely -no-reboot option.
Nikolay
7 years, 11 months
[libvirt] [PATCH v5 00/12] Add runnability info to query-cpu-definitions
by Eduardo Habkost
This series extends query-cpu-definitions to include an extra
field: "unavailable-features". The new field can be used to find
out reasons that prevent the CPU model from running in the
current host.
This will return information based on the current machine and
accelerator only. In the future we may extend these mechanisms to
allow querying other machines and other accelerators without
restarting QEMU, but it will require some reorganization of
QEMU's main code.
To be able to implement this more cleanly, the series rework some
of the feature/property name code.
This series can be seen in the git branch at:
https://github.com/ehabkost/qemu-hacks.git work/query-cpu-definitions-runnable-info
The series is based on my x86-next branch:
https://github.com/ehabkost/qemu.git x86-next
Changes v4 -> v5:
* New patch: "target-i386: Register aliases for feature names with underscores"
* On patch: "tests: Add test case for x86 feature parsing compatibility":
* Fix typo on commit message
Reported-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
* Add comment noting that the "[+-]feature" compatibility mode
will be removed soon
* On patch: "target-i386: Make plus_features/minus_features QOM-based":
* Removed feat2prop() call on , as we now have property aliases
for the old names containing underscores
* On patch: "target-i386: Remove underscores from feat_names arrays":
* Remove the feat2prop() call from the alias registration
loop, too
* Commit message update to enumerate all code that uses
feat_names
* On patch: "target-i386: x86_cpu_load_features() function":
* Fix typo on x86_cpu_load_features() comment
Reported-by: Paolo Bonzini <pbonzini(a)redhat.com>
Diff v4 ->v5:
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4dd3aee..620889f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2002,12 +2002,10 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
/* Compatibility syntax: */
if (featurestr[0] == '+') {
- feat2prop(featurestr + 1);
plus_features = g_list_append(plus_features,
g_strdup(featurestr + 1));
continue;
} else if (featurestr[0] == '-') {
- feat2prop(featurestr + 1);
minus_features = g_list_append(minus_features,
g_strdup(featurestr + 1));
continue;
@@ -3066,8 +3064,7 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
env->features[FEAT_XSAVE_COMP_HI] = mask >> 32;
}
-/* Load CPUID data based on configureured features
- */
+/* Load CPUID data based on configured features */
static void x86_cpu_load_features(X86CPU *cpu, Error **errp)
{
CPUX86State *env = &cpu->env;
@@ -3443,7 +3440,10 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
return;
}
- /* Property names should use "-" instead of "_" */
+ /* Property names should use "-" instead of "_".
+ * Old names containing underscores are registered as aliases
+ * using object_property_add_alias()
+ */
assert(!strchr(name, '_'));
/* aliases don't use "|" delimiters anymore, they are registered
* manually using object_property_add_alias() */
@@ -3496,7 +3496,6 @@ static void x86_cpu_initfn(Object *obj)
}
}
- /* Alias for feature properties: */
object_property_add_alias(obj, "sse3", obj, "pni", &error_abort);
object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq", &error_abort);
object_property_add_alias(obj, "sse4-1", obj, "sse4.1", &error_abort);
@@ -3505,6 +3504,28 @@ static void x86_cpu_initfn(Object *obj)
object_property_add_alias(obj, "ffxsr", obj, "fxsr-opt", &error_abort);
object_property_add_alias(obj, "i64", obj, "lm", &error_abort);
+ object_property_add_alias(obj, "ds_cpl", obj, "ds-cpl", &error_abort);
+ object_property_add_alias(obj, "tsc_adjust", obj, "tsc-adjust", &error_abort);
+ object_property_add_alias(obj, "fxsr_opt", obj, "fxsr-opt", &error_abort);
+ object_property_add_alias(obj, "lahf_lm", obj, "lahf-lm", &error_abort);
+ object_property_add_alias(obj, "cmp_legacy", obj, "cmp-legacy", &error_abort);
+ object_property_add_alias(obj, "nodeid_msr", obj, "nodeid-msr", &error_abort);
+ object_property_add_alias(obj, "perfctr_core", obj, "perfctr-core", &error_abort);
+ object_property_add_alias(obj, "perfctr_nb", obj, "perfctr-nb", &error_abort);
+ object_property_add_alias(obj, "kvm_nopiodelay", obj, "kvm-nopiodelay", &error_abort);
+ object_property_add_alias(obj, "kvm_mmu", obj, "kvm-mmu", &error_abort);
+ object_property_add_alias(obj, "kvm_asyncpf", obj, "kvm-asyncpf", &error_abort);
+ object_property_add_alias(obj, "kvm_steal_time", obj, "kvm-steal-time", &error_abort);
+ object_property_add_alias(obj, "kvm_pv_eoi", obj, "kvm-pv-eoi", &error_abort);
+ object_property_add_alias(obj, "kvm_pv_unhalt", obj, "kvm-pv-unhalt", &error_abort);
+ object_property_add_alias(obj, "svm_lock", obj, "svm-lock", &error_abort);
+ object_property_add_alias(obj, "nrip_save", obj, "nrip-save", &error_abort);
+ object_property_add_alias(obj, "tsc_scale", obj, "tsc-scale", &error_abort);
+ object_property_add_alias(obj, "vmcb_clean", obj, "vmcb-clean", &error_abort);
+ object_property_add_alias(obj, "pause_filter", obj, "pause-filter", &error_abort);
+ object_property_add_alias(obj, "sse4_1", obj, "sse4.1", &error_abort);
+ object_property_add_alias(obj, "sse4_2", obj, "sse4.2", &error_abort);
+
x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
}
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 7cff2b5..260dd27 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -81,9 +81,14 @@ static void test_plus_minus(void)
char *path;
/* Rules:
- * "-foo" overrides "+foo"
- * "[+-]foo" overrides "foo=..."
- * "foo_bar" should be translated to "foo-bar"
+ * 1)"-foo" overrides "+foo"
+ * 2) "[+-]foo" overrides "foo=..."
+ * 3) Old feature names with underscores (e.g. "sse4_2")
+ * should keep working
+ *
+ * Note: rules 1 and 2 are planned to be removed soon, but we
+ * need to keep compatibility for a while until we start
+ * warning users about it.
*/
qtest_start("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,cx8=off,+sse4_1,sse4_2=on");
path = get_cpu0_qom_path();
Changes v3 -> v4:
* Removed patch "Define CPUID filtering functions before x86_cpu_list"
* New patch: "tests: Add test case for x86 feature parsing compatibility"
* New patch: "target-i386: Disable VME by default with TCG"
* Disable VME by default on TCG to avoid returning bogus
results for all CPU models in TCG mode
* New patch: "target-i386: Make plus_features/minus_features QOM-based"
* New patch: "target-i386: Remove underscores from property names"
* New patch: "target-i386: Register properties for feature aliases manually"
* New patch: "target-i386: xsave: Add FP and SSE bits to x86_ext_save_areas"
* New patch: "target-i386: x86_cpu_load_features() function"
* On patch: "target-i386: Return runnability information on query-cpu-definitions"
* Added code to handle unsupported XSAVE components cleanly
* Use x86_cpu_load_features() function
Changes v2 -> v3:
* Small documentation reword
* Suggested-by: Markus Armbruster <armbru(a)redhat.com>
* Create a x86_cpu_feature_name() function, to
isolate the code that returns the property name
Changes v1 -> v2:
* Fixed documentation to say "(since 2.7)"
* Removed @runnable field, improved documentation
Example command output:
{ "return": [
{
"unavailable-features": [],
"static": false,
"name": "host"
},
{
"unavailable-features": [],
"static": false,
"name": "qemu64"
},
{
"unavailable-features": [],
"static": false,
"name": "qemu32"
},
{
"unavailable-features": ["npt", "sse4a", "3dnow", "3dnowext", "fxsr-opt", "mmxext"],
"static": false,
"name": "phenom"
},
{
"unavailable-features": [],
"static": false,
"name": "pentium3"
},
{
"unavailable-features": [],
"static": false,
"name": "pentium2"
},
{
"unavailable-features": [],
"static": false,
"name": "pentium"
},
{
"unavailable-features": [],
"static": false,
"name": "n270"
},
{
"unavailable-features": [],
"static": false,
"name": "kvm64"
},
{
"unavailable-features": [],
"static": false,
"name": "kvm32"
},
{
"unavailable-features": [],
"static": false,
"name": "coreduo"
},
{
"unavailable-features": [],
"static": false,
"name": "core2duo"
},
{
"unavailable-features": ["3dnow", "3dnowext", "mmxext"],
"static": false,
"name": "athlon"
},
{
"unavailable-features": [],
"static": false,
"name": "Westmere"
},
{
"unavailable-features": ["xgetbv1", "xsavec", "3dnowprefetch", "smap", "adx", "rdseed", "mpx", "rtm", "hle"],
"static": false,
"name": "Skylake-Client"
},
{
"unavailable-features": [],
"static": false,
"name": "SandyBridge"
},
{
"unavailable-features": [],
"static": false,
"name": "Penryn"
},
{
"unavailable-features": ["tbm", "fma4", "xop", "3dnowprefetch", "misalignsse", "sse4a"],
"static": false,
"name": "Opteron_G5"
},
{
"unavailable-features": ["fma4", "xop", "3dnowprefetch", "misalignsse", "sse4a"],
"static": false,
"name": "Opteron_G4"
},
{
"unavailable-features": ["misalignsse", "sse4a"],
"static": false,
"name": "Opteron_G3"
},
{
"unavailable-features": [],
"static": false,
"name": "Opteron_G2"
},
{
"unavailable-features": [],
"static": false,
"name": "Opteron_G1"
},
{
"unavailable-features": [],
"static": false,
"name": "Nehalem"
},
{
"unavailable-features": [],
"static": false,
"name": "IvyBridge"
},
{
"unavailable-features": ["rtm", "hle"],
"static": false,
"name": "Haswell"
},
{
"unavailable-features": [],
"static": false,
"name": "Haswell-noTSX"
},
{
"unavailable-features": [],
"static": false,
"name": "Conroe"
},
{
"unavailable-features": ["3dnowprefetch", "smap", "adx", "rdseed", "rtm", "hle"],
"static": false,
"name": "Broadwell"
},
{
"unavailable-features": ["3dnowprefetch", "smap", "adx", "rdseed"],
"static": false,
"name": "Broadwell-noTSX"
},
{
"unavailable-features": [],
"static": false,
"name": "486"
}
]}
Cc: David Hildenbrand <dahi(a)linux.vnet.ibm.com>
Cc: Michael Mueller <mimu(a)linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger(a)de.ibm.com>
Cc: Cornelia Huck <cornelia.huck(a)de.ibm.com>
Cc: Jiri Denemark <jdenemar(a)redhat.com>
Cc: libvir-list(a)redhat.com
Eduardo Habkost (12):
tests: Add test case for x86 feature parsing compatibility
target-i386: List CPU models using subclass list
target-i386: Disable VME by default with TCG
target-i386: Register aliases for feature names with underscores
target-i386: Make plus_features/minus_features QOM-based
target-i386: Remove underscores from feat_names arrays
target-i386: Register properties for feature aliases manually
target-i386: xsave: Add FP and SSE bits to x86_ext_save_areas
target-i386: Move warning code outside x86_cpu_filter_features()
target-i386: x86_cpu_load_features() function
qmp: Add runnability information to query-cpu-definitions
target-i386: Return runnability information on query-cpu-definitions
qapi-schema.json | 23 +-
target-i386/cpu-qom.h | 4 +
target-i386/cpu.c | 510 ++++++++++++++++++++++++++----------------
tests/test-x86-cpuid-compat.c | 44 ++++
4 files changed, 388 insertions(+), 193 deletions(-)
--
2.7.4
8 years
[libvirt] [PATCH v3 00/18] Use mode PCIe less legacy PCI
by Laine Stump
(this time with auto-root-port-add goodness!)
Last month I posted a short patch series that attempted to auto-assign
addresses on PCI Express controllers to devices that were PCI Express
devices.
https://www.redhat.com/archives/libvir-list/2016-August/msg00732.html
In particular, it would assign PCI virtio-1.0 devices, e1000e network
devices, and nec-usb-xhci devices to hotpluggable PCIe express ports
*if any were available*. However, a basic PCIe machine doesn't have
any hotpluggable PCIe ports, and the patchset I sent had no provision
for automatically adding any.
This new patchset takes care of that limitation by automatically
adding pci-root-ports as they are needed, and also automatically adds
a dmi-to-pci-bridge device (to create a legacy PCI bus hierarchy) when
needed so that we can do away with the code that *always* adds one
(and there is a patch that *does* do away with that code :-).
Once all of that was done, it turned out that virt-manager could
create an *almost* legacy-PCI-free Q35 domain config - the only legacy
PCI device was the sound device. Since the ich9 sound device is
integrated into the Intel ich9 chip (which is part of real Q35
hardware), as a curiousity I made an RFC patch that attempts to place
any ich9 audio device at 00:1B.0, which is the address where real Q35
hardware puts this device. With that patch in place, all you have to
do to get a legacy-free Q35 config out of virt-manager is switch the
sound device model from ich6 to ich9. (I don't expect that patch will
be pushed, but it's nice to see this result).
Although Andrea had ACKed most of the patches in the last patchset, I
hadn't wanted to push them without accompanying patches to auto-add
the pcie-root-ports (since doing so would render virt-manager +
new libvirt unusable for Q35 domains). Since then I've decided on a
cleaner manner for setting device connectFlags, so all but Patch 1 of
the last set was discarded and re-written from scratch.
Although there are still a couple more things I'd like to do, these
patches can be pushed without a serious regression in functionality
for Q35 domains:
1) currently I put each new pcie-root-port on its own slot, rather
than putting 8 of them on the different functions of a single
slot. This means you can only get ~30 devices before you have to start
manually adding pcie controllers. That will be remedied soon.
2) I don't have a patch yet to read a PCI device's capabilities to see
whether or not it is an Express device and change the connectFlags
accordingly. In the meantime if you want to plug in a vfio assigned
device, you'll either need to manually address it to a PCIe port, or
you'll need to manually add a pci-bridge device to the config.
3) I don't do anything to assure there are any unused pcie-root-ports
available for hotplug. We need to fix that, but I'm not sure how many
to "reserve". Suggestions I've heard have been "1", "2", "4", and
"just add pcie-root-ports 8 at a time and you'll have 'something
between 1 and 8' available".
Laine Stump (18):
conf: restrict what type of buses will accept a pci-bridge
qemu: replace a lot of "def->controllers[i]" with equivalent "cont"
qemu: new functions qemuDomainMachineHasPCI[e]Root()
qemu: new functions qemuDomainDeviceConnectFlags*()
conf: new function virDomainPCIAddressReserveNextAddr()
qemu: use virDomainPCIAddressReserveNextAddr in
qemuDomainAssignDevicePCISlots
conf: make virDomainPCIAddressGetNextSlot() a local static function
qemu: replace calls to virDomainPCIAddressReserveNext*() with static
function
qemu: set/use info->pciConnectFlags during
qemuDomainAssignDevicePCISlots
qemu: set/use proper pciConnectFlags during hotplug
qemu: assign virtio devices to PCIe slot when appropriate
qemu: assign e1000e network devices to PCIe slots when appropriate
qemu: assign nec-xhci (USB3) controller to a PCIe address when
appropriate
qemu: only force an available legacy-PCI slot on domains with pci-root
qemu: auto-add pcie-root-port/dmi-to-pci-bridge controllers as needed
qemu: don't force-add a dmi-to-pci-bridge just on principle
qemu: add a USB3 controller to Q35 domains by default
[RFC] qemu: try to put ich9 sound device at 00:1B.0
src/conf/device_conf.h | 5 +
src/conf/domain_addr.c | 180 ++++-
src/conf/domain_addr.h | 15 +-
src/libvirt_private.syms | 2 +-
src/qemu/qemu_domain.c | 50 +-
src/qemu/qemu_domain.h | 2 +
src/qemu/qemu_domain_address.c | 802 +++++++++++++++------
src/qemu/qemu_domain_address.h | 4 +
src/qemu/qemu_hotplug.c | 25 +-
tests/qemuxml2argvdata/qemuxml2argv-autoindex.args | 10 +-
tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args | 3 +-
.../qemuxml2argv-q35-default-devices-only.args | 22 +
.../qemuxml2argv-q35-default-devices-only.xml | 18 +
.../qemuxml2argv-q35-pcie-autoadd.args | 56 ++
.../qemuxml2argv-q35-pcie-autoadd.xml | 51 ++
tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.args | 58 ++
tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.xml | 67 ++
.../qemuxml2argv-q35-virt-manager-basic.args | 56 ++
.../qemuxml2argv-q35-virt-manager-basic.xml | 76 ++
.../qemuxml2argv-q35-virtio-pci.args | 58 ++
.../qemuxml2argv-q35-virtio-pci.xml | 1 +
tests/qemuxml2argvtest.c | 123 ++++
.../qemuxml2xmlout-autoindex.xml | 10 +-
.../qemuxml2xmlout-pcie-root.xml | 4 -
.../qemuxml2xmlout-q35-default-devices-only.xml | 40 +
.../qemuxml2xmlout-q35-pcie-autoadd.xml | 143 ++++
.../qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie.xml | 152 ++++
.../qemuxml2xmlout-q35-virt-manager-basic.xml | 116 +++
.../qemuxml2xmlout-q35-virtio-pci.xml | 152 ++++
tests/qemuxml2xmltest.c | 108 +++
30 files changed, 2117 insertions(+), 292 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pci.args
create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pci.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pci.xml
--
2.7.4
8 years
[libvirt] [PATCH RFC] virhook: Adding inotify support to virhook.
by Julio Faracco
Libvirtd only support hooks when the daemon is started. Hooks cannot be
loaded when the daemon is already running. So, to load a hook you need to
restart the service everytime. Now, the inotify support enables the option
of create a hook and run it even if libvirtd was started.
Cc: Carlos Castilho <ccasti(a)br.ibm.com>
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
daemon/libvirtd.c | 1 +
src/libvirt_private.syms | 1 +
src/util/virhook.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++-
src/util/virhook.h | 10 +++
4 files changed, 175 insertions(+), 2 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 95c1b1c..56175d1 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1622,6 +1622,7 @@ int main(int argc, char **argv) {
0, "shutdown", NULL, NULL);
cleanup:
+ virHookCleanUp();
virNetlinkEventServiceStopAll();
virObjectUnref(remoteProgram);
virObjectUnref(lxcProgram);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6a77e46..c8ad816 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1648,6 +1648,7 @@ virHashValueFree;
virHookCall;
virHookInitialize;
virHookPresent;
+virHookCleanUp;
# util/virhostdev.h
diff --git a/src/util/virhook.c b/src/util/virhook.c
index facd74a..d5fc928 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
+#include <sys/inotify.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -45,6 +46,10 @@ VIR_LOG_INIT("util.hook");
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"
+#define virHookInstall(driver) virHooksFound |= (1 << driver);
+
+#define virHookUninstall(driver) virHooksFound ^= (1 << driver);
+
VIR_ENUM_DECL(virHookDriver)
VIR_ENUM_DECL(virHookDaemonOp)
VIR_ENUM_DECL(virHookSubop)
@@ -109,6 +114,8 @@ VIR_ENUM_IMPL(virHookLibxlOp, VIR_HOOK_LIBXL_OP_LAST,
static int virHooksFound = -1;
+static virHookInotifyPtr virHooksInotify = NULL;
+
/**
* virHookCheck:
* @driver: the driver name "daemon", "qemu", "lxc"...
@@ -153,6 +160,121 @@ virHookCheck(int no, const char *driver)
return ret;
}
+/**
+ * virHookInotifyEvent:
+ * @fd: inotify file descriptor.
+ *
+ * Identifies file events at libvirt's hook directory.
+ * Install or uninstall hooks on demand. Acording file manipulation.
+ */
+static void
+virHookInotifyEvent(int watch ATTRIBUTE_UNUSED,
+ int fd,
+ int events ATTRIBUTE_UNUSED,
+ void *data ATTRIBUTE_UNUSED)
+{
+ char buf[1024];
+ struct inotify_event *e;
+ int got;
+ int driver;
+ char *tmp, *name;
+
+ VIR_DEBUG("inotify event in virHookInotify()");
+
+reread:
+ got = read(fd, buf, sizeof(buf));
+ if (got == -1) {
+ if (errno == EINTR)
+ goto reread;
+ return;
+ }
+
+ tmp = buf;
+ while (got) {
+ if (got < sizeof(struct inotify_event))
+ return;
+
+ VIR_WARNINGS_NO_CAST_ALIGN
+ e = (struct inotify_event *)tmp;
+ VIR_WARNINGS_RESET
+
+ tmp += sizeof(struct inotify_event);
+ got -= sizeof(struct inotify_event);
+
+ if (got < e->len)
+ return;
+
+ tmp += e->len;
+ got -= e->len;
+
+ name = (char *)&(e->name);
+
+ /* Removing hook file. */
+ if (e->mask & (IN_DELETE | IN_MOVED_FROM)) {
+ if ((driver = virHookDriverTypeFromString(name)) < 0) {
+ VIR_DEBUG("Invalid hook name for %s", name);
+ return;
+ }
+
+ virHookUninstall(driver);
+ }
+
+ /* Creating hook file. */
+ if (e->mask & (IN_CREATE | IN_CLOSE_WRITE | IN_MOVED_TO)) {
+ if ((driver = virHookDriverTypeFromString(name)) < 0) {
+ VIR_DEBUG("Invalid hook name for %s", name);
+ return;
+ }
+
+ virHookInstall(driver);
+ }
+ }
+}
+
+/**
+ * virHookInotifyInit:
+ *
+ * Initialize inotify hooks support.
+ * Enable hooks installation on demand.
+ *
+ * Returns 0 if inotify was successfully installed, -1 in case of failure.
+ */
+static int
+virHookInotifyInit(void) {
+
+ if (VIR_ALLOC(virHooksInotify) < 0)
+ goto error;
+
+ if ((virHooksInotify->inotifyFD = inotify_init()) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize inotify"));
+ goto error;
+ }
+
+ if ((virHooksInotify->inotifyWatch =
+ inotify_add_watch(virHooksInotify->inotifyFD,
+ LIBVIRT_HOOK_DIR,
+ IN_CREATE | IN_MODIFY | IN_DELETE)) < 0) {
+ virReportSystemError(errno, _("Failed to create inotify watch on %s"),
+ LIBVIRT_HOOK_DIR);
+ goto error;
+ }
+
+ if ((virHooksInotify->inotifyHandler =
+ virEventAddHandle(virHooksInotify->inotifyFD,
+ VIR_EVENT_HANDLE_READABLE,
+ virHookInotifyEvent, NULL, NULL)) < 0) {
+ VIR_DEBUG("Failed to add inotify handle in virHook.");
+ goto error;
+ }
+
+ return 0;
+
+error:
+ virHookCleanUp();
+ return -1;
+}
+
+
/*
* virHookInitialize:
*
@@ -174,10 +296,14 @@ virHookInitialize(void)
return -1;
if (res == 1) {
- virHooksFound |= (1 << i);
+ virHookInstall(i);
ret++;
}
}
+
+ if (virHookInotifyInit() < 0)
+ VIR_INFO("Disabling hooks inotify support.");
+
return ret;
}
@@ -309,7 +435,12 @@ virHookCall(int driver,
if (output)
virCommandSetOutputBuffer(cmd, output);
- ret = virCommandRun(cmd, NULL);
+ ret = virHookCheck(driver, virHookDriverTypeToString(driver));
+
+ if (ret > 0) {
+ ret = virCommandRun(cmd, NULL);
+ }
+
if (ret < 0) {
/* Convert INTERNAL_ERROR into known error. */
virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s",
@@ -322,3 +453,33 @@ virHookCall(int driver,
return ret;
}
+
+/**
+ * virHookCall:
+ *
+ * Release all structures and data used in virhooks.
+ *
+ * Returns: 0 if the execution succeeded
+ */
+int
+virHookCleanUp(void)
+{
+ if (!virHooksInotify)
+ return -1;
+
+ if ((virHooksInotify->inotifyFD >= 0) &&
+ (virHooksInotify->inotifyWatch >= 0))
+ if (inotify_rm_watch(virHooksInotify->inotifyFD,
+ virHooksInotify->inotifyWatch) < 0)
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot remove inotify watcher."));
+
+ if (virHooksInotify->inotifyHandler >= 0)
+ virEventRemoveHandle(virHooksInotify->inotifyHandler);
+
+ VIR_FORCE_CLOSE(virHooksInotify->inotifyFD);
+ VIR_FREE(virHooksInotify);
+
+ virHooksFound = -1;
+
+ return 0;
+}
diff --git a/src/util/virhook.h b/src/util/virhook.h
index 205249c..47a32c7 100644
--- a/src/util/virhook.h
+++ b/src/util/virhook.h
@@ -100,6 +100,14 @@ typedef enum {
VIR_HOOK_LIBXL_OP_LAST,
} virHookLibxlOpType;
+struct _virHookInotify {
+ int inotifyFD;
+ int inotifyWatch;
+ int inotifyHandler;
+};
+
+typedef struct _virHookInotify *virHookInotifyPtr;
+
int virHookInitialize(void);
int virHookPresent(int driver);
@@ -107,4 +115,6 @@ int virHookPresent(int driver);
int virHookCall(int driver, const char *id, int op, int sub_op,
const char *extra, const char *input, char **output);
+int virHookCleanUp(void);
+
#endif /* __VIR_HOOKS_H__ */
--
2.7.4
8 years
[libvirt] [PATCH 0/3] vz: nettype=bridge and other corrections
by Maxim Nestratov
Maxim Nestratov (3):
vz: support type=bridge network interface type correctly
vz: remove Bridged network name and rename Routed
vz: add MIGRATION_V3 capability
src/vz/vz_driver.c | 1 +
src/vz/vz_sdk.c | 100 ++++++++---------------------------------------------
src/vz/vz_utils.h | 3 +-
3 files changed, 16 insertions(+), 88 deletions(-)
--
2.4.11
8 years