[libvirt] [PATCH] Document that virNodeGetInfo can return mhz == 0.
by Richard W.M. Jones
On the s/390x architecture, libvirt may already return 0 in the
node_info->mhz field (see src/nodeinfo.c:linuxNodeInfoCPUPopulate).
We may also want to return this on aarch64 in future, because
calculating the proper value requires SMBIOS, which is not available
on non-server-class systems (specifically on systems which don't
adhere to the SBSA standard).
Therefore this change documents the existing behaviour and provides a
valid path for aarch64.
Signed-off-by: Richard W.M. Jones <rjones(a)redhat.com>
Bug-URL: https://bugzilla.redhat.com/1206353
---
include/libvirt/libvirt-host.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 953366b..070550b 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -354,7 +354,8 @@ struct _virNodeInfo {
char model[32]; /* string indicating the CPU model */
unsigned long memory; /* memory size in kilobytes */
unsigned int cpus; /* the number of active CPUs */
- unsigned int mhz; /* expected CPU frequency */
+ unsigned int mhz; /* expected CPU frequency, 0 if not known or
+ on unusual architectures */
unsigned int nodes; /* the number of NUMA cell, 1 for unusual NUMA
topologies or uniform memory access; check
capabilities XML for the actual NUMA topology */
--
2.3.1
9 years, 4 months
[libvirt] [java] [PATCH 0/6] Fix JNA wrapping, fix memory leaks and wrap security model / label function
by Claudio Bley
Hi.
First and foremost, this series fixes a few mistakes in the wrapping
code found by inspecting the org.libvirt.jna.Libvirt interface and the
corresponding C types of the XML API file.
The last two patches add two missing functions introduced in libvirt
0.6.1.
At the end of the day, this means libvirt-java has gained full
coverage of the libvirt functions up to and including version
0.8.5. Yay!
Claudio Bley (6):
JNA: fix wrong return type void vs. int
JNA: add CString class and fix memory leaks
JNA: simplify freeing memory for C strings
Use the CString class for Arrays of CStrings too
Implement Domain.getSecurityLabel and add SecurityLabel class
Implement Connect.getSecurityModel and add SecurityModel class
src/main/java/org/libvirt/Connect.java | 74 +++++++++--------
src/main/java/org/libvirt/Device.java | 9 +-
src/main/java/org/libvirt/Domain.java | 57 ++++++-------
src/main/java/org/libvirt/DomainSnapshot.java | 8 +-
src/main/java/org/libvirt/Interface.java | 7 +-
src/main/java/org/libvirt/Library.java | 44 +++-------
src/main/java/org/libvirt/Network.java | 14 +---
src/main/java/org/libvirt/NetworkFilter.java | 2 +-
src/main/java/org/libvirt/Secret.java | 2 +-
src/main/java/org/libvirt/SecurityLabel.java | 49 +++++++++++
src/main/java/org/libvirt/SecurityModel.java | 37 +++++++++
src/main/java/org/libvirt/StoragePool.java | 9 +-
src/main/java/org/libvirt/StorageVol.java | 16 +---
src/main/java/org/libvirt/jna/CString.java | 85 +++++++++++++++++++
src/main/java/org/libvirt/jna/Libvirt.java | 114 +++++++++++++++++---------
15 files changed, 343 insertions(+), 184 deletions(-)
create mode 100644 src/main/java/org/libvirt/SecurityLabel.java
create mode 100644 src/main/java/org/libvirt/SecurityModel.java
create mode 100644 src/main/java/org/libvirt/jna/CString.java
--
2.2.2
9 years, 4 months
[libvirt] [PATCH v2 0/4] fix ejecting removable media and some cleanup
by Pavel Hrdina
Pavel Hrdina (4):
virCondWaitUntil: add another return value
virDomainObjSignal: drop this function
monitor: detect that eject fails because the tray is locked
qemu_hotplug: try harder to eject media
src/conf/domain_conf.c | 27 ++++++++--------
src/conf/domain_conf.h | 1 -
src/libvirt_private.syms | 1 -
src/qemu/qemu_hotplug.c | 73 +++++++++++++++++++++-----------------------
src/qemu/qemu_monitor_json.c | 14 +++++++++
src/qemu/qemu_monitor_text.c | 10 ++++++
src/qemu/qemu_process.c | 6 ++--
7 files changed, 77 insertions(+), 55 deletions(-)
--
2.4.4
9 years, 4 months
[libvirt] [PATCH] conf: Don't allow duplicated targets regardless of bus
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1142631
Commit id 'e0e290552' added a check to determine if the same bus
had the same target value. It seems that's not quite good enough
as the check should check the target name value regardless of bus type.
Also added a DO_TEST_DIFFERENT to exhibit the issue
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.c | 3 +-
.../qemuxml2argv-disk-same-targets.xml | 35 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
3 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b10f6cd..7855bcb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12590,8 +12590,7 @@ virDomainDiskDefDstDuplicates(virDomainDefPtr def)
for (i = 1; i < def->ndisks; i++) {
for (j = 0; j < i; j++) {
- if (def->disks[i]->bus == def->disks[j]->bus &&
- STREQ(def->disks[i]->dst, def->disks[j]->dst)) {
+ if (STREQ(def->disks[i]->dst, def->disks[j]->dst)) {
virReportError(VIR_ERR_XML_ERROR,
_("target '%s' duplicated for disk sources "
"'%s' and '%s'"),
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml
new file mode 100644
index 0000000..3276ce5
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/usbdisk.img'/>
+ <target dev='sda' bus='usb'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/idedisk.img'/>
+ <target dev='sda' bus='ide'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/scsidisk.img'/>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index be82dd2..b066681 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -882,6 +882,9 @@ mymain(void)
QEMU_CAPS_DEVICE);
DO_TEST("disk-snapshot",
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
+ DO_TEST_FAILURE("disk-same-targets",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_SCSI_LSI,
+ QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("event_idx",
QEMU_CAPS_DRIVE,
QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
--
2.1.0
9 years, 4 months
[libvirt] [PATCH 00/10] Implement shared memory device - Part 1
by Luyao Huang
This part contains some small fix and Implement the hot-plug/hot-unplug
and cold-plug/cold-unplug for Inter-VM Shared Memory PCI device.
Luyao Huang (10):
qemu: auto assign pci address for shared memory device
qemu: always build id when generate shared memory device CLI
qemu: Refactor creation of shared memory device commandline
conf: use virDomainChrSourceDef to save the path
conf:audit: introduce audit function for shared memory device
conf: Add helpers to insert/remove/find shmem devices in domain def
qemu: Implement shared memory device cold (un)plug
qemu: Implement share memory device hot-plug
qemu: Implement shared memory device hot-unplug
qemu: report error when shmem have a invalid address
docs/auditlog.html.in | 16 +++
src/conf/domain_audit.c | 16 +++
src/conf/domain_audit.h | 6 +
src/conf/domain_conf.c | 69 ++++++++++-
src/conf/domain_conf.h | 9 +-
src/libvirt_private.syms | 5 +
src/qemu/qemu_command.c | 82 +++++++------
src/qemu/qemu_command.h | 7 ++
src/qemu/qemu_driver.c | 35 +++++-
src/qemu/qemu_hotplug.c | 156 ++++++++++++++++++++++++-
src/qemu/qemu_hotplug.h | 6 +
tests/qemuxml2argvdata/qemuxml2argv-shmem.args | 16 +--
12 files changed, 372 insertions(+), 51 deletions(-)
--
1.8.3.1
9 years, 4 months
[libvirt] [[PATCH v5] autocreate tap device for VIR_DOMAIN_NET_TYPE_ETHERNET] autocreate tap device for VIR_DOMAIN_NET_TYPE_ETHERNET
by Vasiliy Tolstov
If a user specify ehernet device create it via libvirt and run
script if it provided. After this commit user does not need to
run external script to create tap device or add root to qemu
process.
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/qemu/qemu_command.c | 139 ++++++++++++++++++++++++++++++------------------
src/qemu/qemu_hotplug.c | 13 ++---
src/qemu/qemu_process.c | 6 +++
3 files changed, 98 insertions(+), 60 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3886b4f..f9008e4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -332,10 +332,39 @@ static int qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
return *tapfd < 0 ? -1 : 0;
}
+/**
+ * qemuExecuteEthernetScript:
+ * @ifname: the interface name
+ * @script: the script name
+ *
+ * This function executes script for new tap device created by libvirt.
+ * Returns 0 in case of success or -1 on failure
+ */
+static int
+qemuExecuteEthernetScript(const char *ifname, const char *script)
+{
+ virCommandPtr cmd;
+ int ret;
+
+ cmd = virCommandNew(script);
+ virCommandAddArgFormat(cmd, "%s", ifname);
+ virCommandClearCaps(cmd);
+#ifdef CAP_NET_ADMIN
+ virCommandAllowCap(cmd, CAP_NET_ADMIN);
+#endif
+ virCommandAddEnvPassCommon(cmd);
+
+ ret = virCommandRun(cmd, NULL);
+
+ virCommandFree(cmd);
+ return ret;
+}
+
/* qemuNetworkIfaceConnect - *only* called if actualType is
- * VIR_DOMAIN_NET_TYPE_NETWORK or VIR_DOMAIN_NET_TYPE_BRIDGE (i.e. if
- * the connection is made with a tap device connecting to a bridge
- * device)
+ * VIR_DOMAIN_NET_TYPE_NETWORK, VIR_DOMAIN_NET_TYPE_BRIDGE
+ * VIR_DOMAIN_NET_TYPE_ETHERNET (i.e. if the connection is
+ * made with a tap device connecting to a bridge device or
+ * use plain tap device)
*/
int
qemuNetworkIfaceConnect(virDomainDefPtr def,
@@ -351,6 +380,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
bool template_ifname = false;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
const char *tunpath = "/dev/net/tun";
+ virMacAddr tapmac;
if (net->backend.tap) {
tunpath = net->backend.tap;
@@ -361,11 +391,6 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
}
}
- if (!(brname = virDomainNetGetActualBridgeName(net))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing bridge name"));
- goto cleanup;
- }
-
if (!net->ifname ||
STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
strchr(net->ifname, '%')) {
@@ -381,40 +406,62 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
}
- if (cfg->privileged) {
- if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
- def->uuid, tunpath, tapfd, *tapfdSize,
- virDomainNetGetActualVirtPortProfile(net),
- virDomainNetGetActualVlan(net),
- tap_create_flags) < 0) {
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_ETHERNET) {
+ if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, *tapfdSize,
+ tap_create_flags) < 0) {
virDomainAuditNetDevice(def, net, tunpath, false);
goto cleanup;
}
- if (virDomainNetGetActualBridgeMACTableManager(net)
- == VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
- /* libvirt is managing the FDB of the bridge this device
- * is attaching to, so we need to turn off learning and
- * unicast_flood on the device to prevent the kernel from
- * adding any FDB entries for it. We will add add an fdb
- * entry ourselves (during qemuInterfaceStartDevices(),
- * using the MAC address from the interface config.
- */
- if (virNetDevBridgePortSetLearning(brname, net->ifname, false) < 0)
- goto cleanup;
- if (virNetDevBridgePortSetUnicastFlood(brname, net->ifname, false) < 0)
+ virMacAddrSet(&tapmac, &net->mac);
+
+ if (virNetDevSetMAC(net->ifname, &tapmac) < 0)
+ goto cleanup;
+
+ if (net->script) {
+ if (qemuExecuteEthernetScript(net->ifname, net->script) < 0)
goto cleanup;
}
} else {
- if (qemuCreateInBridgePortWithHelper(cfg, brname,
- &net->ifname,
- tapfd, tap_create_flags) < 0) {
- virDomainAuditNetDevice(def, net, tunpath, false);
+ if (!(brname = virDomainNetGetActualBridgeName(net))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing bridge name"));
goto cleanup;
}
- /* qemuCreateInBridgePortWithHelper can only create a single FD */
- if (*tapfdSize > 1) {
- VIR_WARN("Ignoring multiqueue network request");
- *tapfdSize = 1;
+
+ if (cfg->privileged) {
+ if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
+ def->uuid, tunpath, tapfd, *tapfdSize,
+ virDomainNetGetActualVirtPortProfile(net),
+ virDomainNetGetActualVlan(net),
+ tap_create_flags) < 0) {
+ virDomainAuditNetDevice(def, net, tunpath, false);
+ goto cleanup;
+ }
+ if (virDomainNetGetActualBridgeMACTableManager(net)
+ == VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
+ /* libvirt is managing the FDB of the bridge this device
+ * is attaching to, so we need to turn off learning and
+ * unicast_flood on the device to prevent the kernel from
+ * adding any FDB entries for it. We will add add an fdb
+ * entry ourselves (during qemuInterfaceStartDevices(),
+ * using the MAC address from the interface config.
+ */
+ if (virNetDevBridgePortSetLearning(brname, net->ifname, false) < 0)
+ goto cleanup;
+ if (virNetDevBridgePortSetUnicastFlood(brname, net->ifname, false) < 0)
+ goto cleanup;
+ }
+ } else {
+ if (qemuCreateInBridgePortWithHelper(cfg, brname,
+ &net->ifname,
+ tapfd, tap_create_flags) < 0) {
+ virDomainAuditNetDevice(def, net, tunpath, false);
+ goto cleanup;
+ }
+ /* qemuCreateInBridgePortWithHelper can only create a single FD */
+ if (*tapfdSize > 1) {
+ VIR_WARN("Ignoring multiqueue network request");
+ *tapfdSize = 1;
+ }
}
}
@@ -5221,6 +5268,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
virBufferAsprintf(&buf, "tap%c", type_sep);
/* for one tapfd 'fd=' shall be used,
* for more than one 'fds=' is the right choice */
@@ -5238,20 +5286,6 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
is_tap = true;
break;
- case VIR_DOMAIN_NET_TYPE_ETHERNET:
- virBufferAddLit(&buf, "tap");
- if (net->ifname) {
- virBufferAsprintf(&buf, "%cifname=%s", type_sep, net->ifname);
- type_sep = ',';
- }
- if (net->script) {
- virBufferAsprintf(&buf, "%cscript=%s", type_sep,
- net->script);
- type_sep = ',';
- }
- is_tap = true;
- break;
-
case VIR_DOMAIN_NET_TYPE_CLIENT:
virBufferAsprintf(&buf, "socket%cconnect=%s:%d",
type_sep,
@@ -8226,7 +8260,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
/* Currently nothing besides TAP devices supports multiqueue. */
if (net->driver.virtio.queues > 0 &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Multiqueue network is not supported for: %s"),
virDomainNetTypeToString(actualType));
@@ -8235,7 +8270,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
if (net->backend.tap &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Custom tap device path is not supported for: %s"),
virDomainNetTypeToString(actualType));
@@ -8245,7 +8281,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
cfg = virQEMUDriverGetConfig(driver);
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
tapfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = 1;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index cc86a3b..21ea3fd 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -908,7 +908,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
/* Currently nothing besides TAP devices supports multiqueue. */
if (net->driver.virtio.queues > 0 &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Multiqueue network is not supported for: %s"),
virDomainNetTypeToString(actualType));
@@ -916,7 +917,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
- actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
+ actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
@@ -947,13 +949,6 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
iface_connected = true;
if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
goto cleanup;
- } else if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
- vhostfdSize = 1;
- if (VIR_ALLOC(vhostfd) < 0)
- goto cleanup;
- *vhostfd = -1;
- if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
- goto cleanup;
}
/* Set device online immediately */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 64ee049..d866e44 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5205,6 +5205,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
cfg->stateDir));
VIR_FREE(net->ifname);
break;
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ if (net->ifname) {
+ ignore_value(virNetDevTapDelete(net->ifname, net->backend.tap));
+ VIR_FREE(net->ifname);
+ }
+ break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
#ifdef VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP
--
2.3.3
9 years, 4 months
[libvirt] [PATCH v2 0/2] Allow PCI virtio on ARM "virt" machine
by Pavel Fedin
Virt machine in qemu since v2.3.0 has PCI generic host controller, and can use
PCI devices. This provides performance improvement as well as vhost-net with
irqfd support for virtio-net. However libvirt still insists on virtio devices
attached to virt machine to have MMIO bindings. This patch allows to use both.
If the user doesn't specify <address type='virtio-mmio'>, PCI will be used by
default.
Changes since v1:
- Added capability based on qemu version number
- Recognize also "virt-" prefix
Pavel Fedin (2):
Introduce QEMU_CAPS_ARM_VIRT_PCI
Allow PCI virtio on ARM "virt" machine
src/qemu/qemu_capabilities.c | 5 +++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 15 ++++++++++++---
3 files changed, 18 insertions(+), 3 deletions(-)
--
1.9.5.msysgit.0
9 years, 4 months
[libvirt] [PATCH 0/2] [V3] Libvirt : Storage fixes
by Prerna Saxena
Here is V3 of storage fixes, which addresses review comments of v2.
Summary:
Prerna Saxena (2):
Storage: Introduce shadow vol for refresh while the main vol builds.
Storage : Fix cloning of raw, sparse volumes
src/storage/storage_backend.c | 23 ++++++++++-------------
src/storage/storage_driver.c | 19 ++++++++++++-------
2 files changed, 22 insertions(+), 20 deletions(-)
V2 :
http://www.redhat.com/archives/libvir-list/2015-June/msg01052.html
Changelog:
Modified patches 1,2 per review comments.
--
1.8.3.1
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
9 years, 4 months
[libvirt] [PATCH] Fix nodeinfo output on PPC64 KVM hosts
by Shivaprasad G Bhat
The nodeinfo is reporting incorrect number of cpus and incorrect host
topology on PPC64 KVM hosts. The KVM hypervisor on PPC64 needs only
the primary thread in a core to be online, and the secondaries offlined.
While scheduling a guest in, the kvm scheduler wakes up the secondaries to
run in guest context.
The host scheduling of the guests happen at the core level(as only primary
thread is online). The kvm scheduler exploits as many threads of the core
as needed by guest. Further, starting POWER8, the processor allows splitting
a physical core into multiple subcores with 2 or 4 threads each. Again, only
the primary thread in a subcore is online in the host. The KVM-PPC
scheduler allows guests to exploit all the offline threads in the subcore,
by bringing them online when needed.
(Kernel patches on split-core http://www.spinics.net/lists/kvm-ppc/msg09121.html)
Recently with dynamic micro-threading changes in ppc-kvm, makes sure
to utilize all the offline cpus across guests, and across guests with
different cpu topologies.
(https://www.mail-archive.com/kvm@vger.kernel.org/msg115978.html)
Since the offline cpus are brought online in the guest context, it is safe
to count them as online. Nodeinfo today discounts these offline cpus from
cpu count/topology calclulation, and the nodeinfo output is not of any help
and the host appears overcommited when it is actually not.
The patch carefully counts those offline threads whose primary threads are
online. The host topology displayed by the nodeinfo is also fixed when the
host is in valid kvm state.
Test results with and without fix:
http://ur1.ca/mx25y
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2fafe2d..1a27080 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -32,6 +32,8 @@
#include <sys/utsname.h>
#include <sched.h>
#include "conf/domain_conf.h"
+#include <fcntl.h>
+#include <sys/ioctl.h>
#if defined(__FreeBSD__) || defined(__APPLE__)
# include <sys/time.h>
@@ -428,6 +430,10 @@ virNodeParseNode(const char *node,
unsigned int cpu;
int online;
int direrr;
+ int kvmfd = -1;
+ int lastonline;
+ int threads_per_subcore = 1;
+ bool valid_ppc64_kvmhost_mode = false;
*threads = 0;
*cores = 0;
@@ -464,6 +470,66 @@ virNodeParseNode(const char *node,
sock_max++;
+ if (ARCH_IS_PPC64(arch)) {
+ /* PPC-KVM needs the secondary threads of a core to be offline on the
+ * host. The kvm schedular brings the secondary threads online in the
+ * guest context. Moreover, P8 processor has split-core capability
+ * where, there can be 1,2 or 4 subcores per core. The primaries of the
+ * subcores alone will be online on the host for a subcore in the
+ * host. Even though the actual threads per core for P8 processor is 8,
+ * depending on the subcores_per_core = 1, 2 or 4, the threads per
+ * subcore will vary accordingly to 8, 4 and 2 repectively.
+ * So, On host threads_per_core what is arrived at from sysfs in the
+ * current logic is actually the subcores_per_core. Threads per subcore
+ * can only be obtained from the kvm device. For example, on P8 wih 1
+ * core having 8 threads, sub_cores_percore=4, the threads 0,2,4 & 6
+ * will be online. The sysfs reflects this and in the current logic
+ * variable 'threads' will be 4 which is nothing but subcores_per_core.
+ * If the user tampers the cpu online/offline states using chcpu or other
+ * means, then it is an unsupported configuration for kvm.
+ * The code below tries to keep in mind
+ * - when the libvirtd is run inside a KVM guest or Phyp based guest.
+ * - Or on the kvm host where user manually tampers the cpu states to
+ * offline/online randomly.
+ */
+# if HAVE_LINUX_KVM_H
+# include <linux/kvm.h>
+ kvmfd = open("/dev/kvm", O_RDONLY);
+ if (kvmfd >= 0) {
+# ifdef KVM_CAP_PPC_SMT
+ valid_ppc64_kvmhost_mode = true;
+ /* For Phyp and KVM based guests the ioctl for KVM_CAP_PPC_SMT
+ * returns zero and both primary and secondary threads will be
+ * online. Dont try to alter or interpret anything here.
+ */
+ threads_per_subcore = ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_PPC_SMT);
+ if (threads_per_subcore == 0)
+ valid_ppc64_kvmhost_mode = false;
+# endif
+ }
+ VIR_FORCE_CLOSE(kvmfd);
+# endif
+ rewinddir(cpudir);
+ lastonline = -1;
+ while (valid_ppc64_kvmhost_mode &&
+ ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0)) {
+ if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
+ continue;
+ if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
+ goto cleanup;
+
+ if (online) {
+ if (lastonline != -1 &&
+ (cpu - lastonline) < threads_per_subcore) {
+ valid_ppc64_kvmhost_mode = false; /* if any of secondaries
+ * online */
+ break;
+ }
+ lastonline = cpu;
+ }
+ }
+ }
+
/* allocate cpu maps for each socket */
if (VIR_ALLOC_N(core_maps, sock_max) < 0)
goto cleanup;
@@ -473,6 +539,7 @@ virNodeParseNode(const char *node,
/* iterate over all CPU's in the node */
rewinddir(cpudir);
+ lastonline = -1;
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
@@ -480,6 +547,17 @@ virNodeParseNode(const char *node,
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
goto cleanup;
+ if (ARCH_IS_PPC64(arch) && valid_ppc64_kvmhost_mode) {
+ if (online) {
+ lastonline = cpu;
+ } else if (lastonline != -1 &&
+ (cpu-lastonline) < threads_per_subcore) {
+ processors++; /* Count only those secondaries whose primary
+ subcore is online */
+ continue;
+ }
+ }
+
if (!online) {
(*offline)++;
continue;
@@ -528,6 +606,13 @@ virNodeParseNode(const char *node,
*cores = core;
}
+ if (ARCH_IS_PPC64(arch) && valid_ppc64_kvmhost_mode) {
+ /* The actual host threads per core is
+ * multiple of the subcores_per_core(i.e variable *threads in this case)
+ * and threads_per_subcore.
+ */
+ *threads = *threads * threads_per_subcore;
+ }
ret = processors;
cleanup:
9 years, 4 months
[libvirt] [PATCH] virsh: report error if vcpu number exceed the guest maxvcpu number
by Luyao Huang
If usr pass a vcpu which exceed guest maxvcpu number, virsh client
will only output an header like this:
# virsh vcpupin test3 1000
VCPU: CPU Affinity
----------------------------------
After this patch:
# virsh vcpupin test3 1000
error: vcpu 1000 is out of range of cpu count 2
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
tools/virsh-domain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 27d62e9..681fc1a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6497,6 +6497,11 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ if (got_vcpu && vcpu >= ncpus) {
+ vshError(ctl, _("vcpu %d is out of range of cpu count %d"), vcpu, ncpus);
+ goto cleanup;
+ }
+
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
cpumap = vshMalloc(ctl, ncpus * cpumaplen);
if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
--
1.8.3.1
9 years, 4 months