[libvirt] [PATCH] util: make it more robust to calculate timeout value
by zhang bo
When we change system clock to years ago, a certain CPU may use up 100% cputime.
The reason is that in function virEventPollCalculateTimeout(), we assign the
unsigned long long result to an INT variable,
*timeout = then - now; // timeout is INT, and then/now are long long
if (*timeout < 0)
*timeout = 0;
there's a chance that variable @then minus variable @now may be a very large number
that overflows INT value expression, then *timeout will be negative and be assigned to 0.
Next the 'poll' in function virEventPollRunOnce() will get into an 'endless' while loop there.
thus, the cpu that virEventPollRunOnce() thread runs on will go up to 100%.
Although as we discussed before in https://www.redhat.com/archives/libvir-list/2015-May/msg00400.html
it should be prohibited to set-time while other applications are running, but it does
seems to have no harm to make the codes more robust.
Signed-off-by: Wang Yufei <james.wangyufei(a)huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo(a)huawei.com>
---
src/util/vireventpoll.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index ffda206..5f5a149 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -357,9 +357,10 @@ static int virEventPollCalculateTimeout(int *timeout)
return -1;
EVENT_DEBUG("Schedule timeout then=%llu now=%llu", then, now);
- *timeout = then - now;
- if (*timeout < 0)
+ if (then < now)
*timeout = 0;
+ else
+ *timeout = (then - now) & 0x7FFFFFFF;
} else {
*timeout = -1;
}
--
1.7.12.4
9 years, 6 months
[libvirt] [PATCH] netdev: assure that SRIOV PF is online before modifying VF params
by Laine Stump
The kernel won't complain if you set the mac address and vlan tag for
an SRIOV VF via its PF, and it will even let you assign the PF to a
guest using PCI device assignment or macvtap passthrough. But if the
PF isn't online, the device won't be usable in the guest. This patch
makes sure that it is turned on.
Since multiple guests/VFs could use the same PF, there is no point in
ever setting the PF *off*line.
This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=893738
Originally filed against RHEL6, but present in every version of
libvirt until today.
---
src/util/virnetdev.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index e14b401..7022dfa 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2258,6 +2258,17 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
char macstr[VIR_MAC_STRING_BUFLEN];
char *fileData = NULL;
int ifindex = -1;
+ bool pfIsOnline;
+
+ /* Assure that PF is online prior to twiddling with the VF. It
+ * *should* be, but if the PF isn't online the changes made to the
+ * VF via the PF won't take effect, yet there will be no error
+ * reported.
+ */
+ if (virNetDevGetOnline(pflinkdev, &pfIsOnline) < 0)
+ return ret;
+ if (!pfIsOnline && virNetDevSetOnline(pflinkdev, true) < 0)
+ return ret;
if (virNetDevGetVfConfig(pflinkdev, vf, &oldmac, &oldvlanid) < 0)
goto cleanup;
--
2.1.0
9 years, 6 months
[libvirt] [PATCH 0/4] Enable support for s390 crypto key mgmt operations
by akrowiak@linux.vnet.ibm.com
From: Tony Krowiak <akrowiak(a)linux.vnet.ibm.com>
The IBM System z Central Processor Assist for Cryptographic Functions (CPACF)
hardware provides a set of CPU instructions for use in clear-key encryption,
pseudo random number generation, hash functions, and protected-key encryption.
The CPACF protected key cryptographic functions operate with a protected key
which is encrypted under a unique wrapping key that is stored in the Hardware
System Area (HSA) of the machine and can only be accessed by firmware. The
wrapping key cannot be accessed by the operating system or application
programs. There are two wrapping keys: One for wrapping AES keys and one for
wrapping DES/TDES keys. This patch set enables the support for encrypting
clear keys under the AES and DES/TDES wrapping keys for guests started on hosts
running on s390 hardware that supports key wrapping.
Tony Krowiak (4):
libvirt: docs: XML to enable/disable protected key mgmt ops
libvirt: conf: parse XML for protected key management ops
libvirt: qemu: enable/disable protected key management ops
libvirt: tests: test protected key mgmt ops support
9 years, 6 months
[libvirt] [PATCHv2 0/9] qemu: fix device alias usage, ide controllers,
by Laine Stump
V1 was here:
http://www.redhat.com/archives/libvir-list/2015-May/msg00124.html
This started out with the intent to generate an error/failure on
request for an IDE controller on a machinetype that doesn't support
IDE (currently anything except 440fx-based machinetypes), or a 2nd IDE
controller on a machinetype that only supports one (i.e. 440fx). This
led to a few other related fixes, and some "fixes related to the
related fixes".
I've pushed some of the ACKed patches, and dropped the two patches
that changed qemuBuildDeviceAddress and qemuAssignDeviceControllerAlias
to use switches instead of "if .. else if .." (03/13 and 04/13) and
dropped the two SCSI patches (12/13 and 13/13), but left a couple of
ACKed patches in for clarity.
Detailed differences from V1 in each patch.
Laine Stump (9):
conf: utility to return alias of a controller based on type/index
qemu: fix exceptions in qemuAssignDeviceControllerAlias
qemu: use controller alias when constructing device/controller args
qemu: use alias to refer to non-multibus PCI controller
qemu: use controller's alias in commandline for scsi-generic
qemu: use USB controller's alias instead of qemuUSBId()
qemu: remove test for allowing ide controller in s390, rename usb
tests
qemu: clean up qemuBuildCommandline loop that builds controller args
qemu: log error when domain has an unsupported IDE controller
src/conf/domain_conf.c | 34 +++
src/conf/domain_conf.h | 3 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 317 +++++++++++----------
src/qemu/qemu_command.h | 6 +-
src/qemu/qemu_hotplug.c | 4 +-
.../qemuxml2argv-disk-blockio.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-disk-blockio.xml | 1 -
.../qemuxml2argv-disk-ide-drive-split.args | 2 +-
.../qemuxml2argv-disk-ide-drive-split.xml | 1 -
.../qemuxml2argv-disk-sata-device.args | 4 +-
.../qemuxml2argv-disk-source-pool-mode.args | 2 +-
.../qemuxml2argv-disk-source-pool-mode.xml | 1 -
.../qemuxml2argv-disk-source-pool.args | 2 +-
.../qemuxml2argv-disk-source-pool.xml | 1 -
...uxml2argv-s390-allow-bogus-usb-controller.args} | 0
...muxml2argv-s390-allow-bogus-usb-controller.xml} | 3 -
...=> qemuxml2argv-s390-allow-bogus-usb-none.args} | 0
... => qemuxml2argv-s390-allow-bogus-usb-none.xml} | 0
tests/qemuxml2argvtest.c | 4 +-
.../qemuxml2xmlout-disk-source-pool.xml | 1 -
21 files changed, 226 insertions(+), 163 deletions(-)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-piix-controllers.args => qemuxml2argv-s390-allow-bogus-usb-controller.args} (100%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-piix-controllers.xml => qemuxml2argv-s390-allow-bogus-usb-controller.xml} (86%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-usb-none.args => qemuxml2argv-s390-allow-bogus-usb-none.args} (100%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-usb-none.xml => qemuxml2argv-s390-allow-bogus-usb-none.xml} (100%)
--
2.1.0
9 years, 6 months
[libvirt] [PATCH v2 0/5] Cleanup storage migration code a bit
by Jiri Denemark
Version 2:
- move QEMU-only data from virDomainDiskDef to a private data object
Jiri Denemark (5):
Add privateData to virDomainDiskDef
Rename virDomainHasBlockjob as qemuDomainHasBlockjob
Move QEMU-only fields from virDomainDiskDef into privateData
qemu: Keep track of what disks are being migrated
qemu: Don't give up on first error in qemuMigrationCancelDriverMirror
src/conf/domain_conf.c | 43 ++++-------------------
src/conf/domain_conf.h | 19 +++-------
src/libvirt_private.syms | 1 -
src/parallels/parallels_sdk.c | 4 +--
src/qemu/qemu_blockjob.c | 48 ++++++++++++++-----------
src/qemu/qemu_command.c | 4 +--
src/qemu/qemu_domain.c | 81 ++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_domain.h | 25 +++++++++++++
src/qemu/qemu_driver.c | 15 ++++----
src/qemu/qemu_migration.c | 42 +++++++++++-----------
src/qemu/qemu_process.c | 17 +++++----
src/vbox/vbox_common.c | 4 +--
src/vbox/vbox_tmpl.c | 6 ++--
src/vmx/vmx.c | 2 +-
src/xenconfig/xen_sxpr.c | 6 ++--
src/xenconfig/xen_xl.c | 2 +-
src/xenconfig/xen_xm.c | 4 +--
17 files changed, 201 insertions(+), 122 deletions(-)
--
2.4.0
9 years, 6 months
[libvirt] Windows Development
by scott lee
I just finished the C# PInvoke portion for the libvirt library.
https://github.com/smasherprog/Libvirt_Windows_Dll
If you download the repo, and execute the powershell script, all
dlls/headers are pulled, and a single C# PInvoke file is generated from the
libvirt header files which contains all enums, callbacks, functions, etc.
It is a complete parse of all headers
libvirt-domain-snapshot.h
libvirt-domain.h
libvirt-event.h
libvirt-host.h
libvirt-interface.h
libvirt-lxc.h
libvirt-network.h
libvirt-nodedev.h
libvirt-nwfilter.h
libvirt-qemu.h
libvirt-secret.h
libvirt-storage.h
libvirt-stream.h
libvirt.h
virterror.h
into a single .cs file that can be used for development -- thanks to the
clang compiler!
Now, I'll create a demo solution for this as well.
9 years, 6 months
[libvirt] [PATCH] docs: add dimm address document in docs
by Luyao Huang
As we have a new device address type 'dimm', add
some document and an example to our docs.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
docs/formatdomain.html.in | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e0b6ba7..0e908a1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2876,6 +2876,13 @@
attributes: <code>iobase</code> and <code>irq</code>.
<span class="since">Since 1.2.1</span>
</dd>
+ <dt><code>type='dimm'</code></dt>
+ <dd>DIMM addresses, for memory device, have the following additional
+ attributes: <code>slot</code> (a value between 0 and 4294967295,
+ inclusive), and <code>base</code> (a hex value between 0 and
+ 0xffffffffffffffff, inclusive).
+ <span class="since">Since 1.2.14</span>
+ </dd>
</dl>
<h4><a name="elementsControllers">Controllers</a></h4>
@@ -6038,6 +6045,7 @@ qemu-kvm -net nic,model=? /dev/null
<size unit='KiB'>524287</size>
<node>0</node>
</target>
+ <address type='dimm' slot='0' base='0x0'/>
</memory>
<memory model='dimm'>
<source>
--
1.8.3.1
9 years, 6 months
[libvirt] [PATCHv2] virsh: fix no error output when parse cpulist fail
by Luyao Huang
When we pass a invalid cpulist or the lastcpu in the
cpulist exceed the maxcpu, we cannot get any error.
like this:
# virsh vcpupin test3 1 aaa
# virsh vcpupin test3 1 1000
Because virBitmapParse() use virReportError() to set
the error message, vshCommandRun would output the error
in vshReportError, but in the meantime it is overwriten
by the virResetLastError in virDomainFree. If we want use
the error which set by virReportError(), we need vshSaveLibvirtError
to help us. However the error from virBitmap is not clearly
enough, i chose use vshError to output error when parse failed.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
v2:
Add the check in vshParseCPUList, because this will make
get last cpu more easier when the cpulist is a bitmap.
tools/virsh-domain.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 14e1e35..20f8c75 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6348,7 +6348,7 @@ vshPrintPinInfo(unsigned char *cpumap, size_t cpumaplen)
}
static unsigned char *
-vshParseCPUList(int *cpumaplen, const char *cpulist, int maxcpu)
+vshParseCPUList(vshControl *ctl, int *cpumaplen, const char *cpulist, int maxcpu)
{
unsigned char *cpumap = NULL;
virBitmapPtr map = NULL;
@@ -6358,8 +6358,17 @@ vshParseCPUList(int *cpumaplen, const char *cpulist, int maxcpu)
return NULL;
virBitmapSetAll(map);
} else {
- if (virBitmapParse(cpulist, '\0', &map, maxcpu) < 0)
- return NULL;
+ if ((virBitmapParse(cpulist, '\0', &map, 1024) < 0) ||
+ virBitmapIsAllClear(map)) {
+ vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
+ goto cleanup;
+ }
+ int lastcpu = virBitmapLastSetBit(map);
+ if (lastcpu >= maxcpu) {
+ vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
+ lastcpu, cpulist, maxcpu);
+ goto cleanup;
+ }
}
if (virBitmapToData(map, &cpumap, cpumaplen) < 0)
@@ -6458,7 +6467,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
}
} else {
/* Pin mode: pinning specified vcpu to specified physical cpus*/
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (flags == -1) {
@@ -6577,7 +6586,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
}
/* Pin mode: pinning emulator threads to specified physical cpus*/
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (flags == -1)
@@ -6862,7 +6871,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
goto cleanup;
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (virDomainPinIOThread(dom, iothread_id,
--
1.8.3.1
9 years, 6 months
[libvirt] [RFC v1 0/6] Live Migration with ephemeral host NIC devices
by Chen Fan
my main goal is to add support migration with host NIC
passthrough devices and keep the network connectivity.
this series patch base on Shradha's patches on
https://www.redhat.com/archives/libvir-list/2012-November/msg01324.html
which is add migration support for host passthrough devices.
1) unplug the ephemeral devices before migration
2) do native migration
3) when migration finished, hotplug the ephemeral devices
TODO:
keep network connectivity on guest level by bonding device.
Chen Fan (6):
conf: add ephemeral element for hostdev supporting migration
qemu: Save ephemeral devices into qemuDomainObjPrivate
qemu: add check ephemeral devices only for PCI host devices
migration: Migration support for ephemeral hostdevs
managedsave: move the domain xml handling forward to stop CPU
managedsave: add managedsave support for ephemeral host devices
docs/schemas/domaincommon.rng | 10 ++
docs/schemas/network.rng | 5 +
src/conf/domain_conf.c | 14 +-
src/conf/domain_conf.h | 1 +
src/conf/network_conf.c | 13 ++
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 1 +
src/qemu/qemu_command.c | 11 ++
src/qemu/qemu_domain.c | 5 +
src/qemu/qemu_domain.h | 3 +
src/qemu/qemu_driver.c | 48 +++---
src/qemu/qemu_migration.c | 182 ++++++++++++++++++++-
src/qemu/qemu_migration.h | 9 +
src/qemu/qemu_process.c | 12 ++
tests/networkxml2xmlin/hostdev-pf.xml | 2 +-
tests/networkxml2xmlin/hostdev.xml | 2 +-
tests/networkxml2xmlout/hostdev-pf.xml | 2 +-
tests/networkxml2xmlout/hostdev.xml | 2 +-
.../qemuxml2argv-controller-order.xml | 2 +-
.../qemuxml2argv-hostdev-pci-address-device.xml | 2 +-
.../qemuxml2argv-hostdev-pci-address.xml | 2 +-
.../qemuxml2argv-hostdev-scsi-autogen-address.xml | 22 +--
.../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml | 4 +-
.../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml | 4 +-
.../qemuxml2argv-hostdev-scsi-lsi.xml | 2 +-
.../qemuxml2argv-hostdev-scsi-rawio.xml | 2 +-
.../qemuxml2argv-hostdev-scsi-readonly.xml | 2 +-
.../qemuxml2argv-hostdev-scsi-sgio.xml | 2 +-
.../qemuxml2argv-hostdev-scsi-shareable.xml | 2 +-
...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml | 4 +-
.../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml | 4 +-
.../qemuxml2argv-hostdev-scsi-virtio-scsi.xml | 2 +-
...emuxml2argv-hostdev-usb-address-device-boot.xml | 2 +-
.../qemuxml2argv-hostdev-usb-address-device.xml | 2 +-
.../qemuxml2argv-hostdev-usb-address.xml | 2 +-
.../qemuxml2argv-hostdev-vfio-multidomain.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml | 2 +-
.../qemuxml2argv-net-hostdev-multidomain.xml | 2 +-
.../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 2 +-
.../qemuxml2argv-net-hostdev-vfio.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-pci-rom.xml | 4 +-
...qemuxml2xmlout-hostdev-scsi-autogen-address.xml | 22 +--
43 files changed, 340 insertions(+), 83 deletions(-)
--
1.9.3
9 years, 6 months