[libvirt] [PATCH] gitignore: ignore more files
by liguang
ignore *.patch, cscope.po.out, cscope.in.out
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
.gitignore | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 1cd2d45..d2d6657 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
*.pyc
*.rej
*.s
+*.patch
*~
.deps
.gdb_history
@@ -185,6 +186,8 @@ TAGS
coverage
cscope.files
cscope.out
+cscope.in.out
+cscope.po.out
results.log
stamp-h
stamp-h.in
--
1.7.1
12 years
[libvirt] How you can help with maintenance releases
by Cole Robinson
Hey all,
As you're likely aware, I've been cutting maintenance releases of certain
libvirt versions for the past six months:
http://wiki.libvirt.org/page/Maintenance_Releases
Since I'm not hugely involved with development these days, and things move
pretty quick in libvirt land, I'd like to appeal to you fine gentleman for a
bit of assistance here. None of this is mandatory, but hopefully it's low
enough effort that I get a few bites :) Here's the gist:
Next time you post a bug fix for an issue you can imagine someone actually
hitting and filing a bug report about, consider doing one of the following:
- Pushing the patch to the relevant maint branches
- CCing me on the posting, with a note that this might be a maint candidate
Of course, doing this for patches that someone else posts is completely fine
with me too :)
Take a look at the current branched versions and their original release dates:
libvirt 0.9.6: Sep 22 2011
libvirt 0.9.11: Apr 3 2012
libvirt 0.10.2: September 24 2012
So if you find a bug in code that you know hasn't been touched for a year, it
might be a candidate for all 3 branches! Jiri recently noticed this and
cherry-picked a patch, (which was very much appreciated!):
http://libvirt.org/git/?p=libvirt.git;a=commit;h=bebe5122b9af50f0b25f47f3...
http://libvirt.org/git/?p=libvirt.git;a=commit;h=d325704a3fdf947fa862bf62...
http://libvirt.org/git/?p=libvirt.git;a=commit;h=77cecd2bc306416d985230bb...
As an example of how to push a patch to a maintenance branch, say you want to
backport master commit ab12cd34:
git checkout --track remotes/origin/v0.10.2-maint
git checkout v0.10.2-maint
git cherry-pick -x ab12cd34
git push v0.10.2-maint
If the cherry-pick doesn't apply cleanly, feel free to just CC me and I'll
straighten it out.
That's it! Let me know if you have any questions.
Thanks,
Cole
12 years
[libvirt] ANNOUNCE: libvirt 0.10.2.1 maintenance release
by Cole Robinson
libvirt 0.10.2.1 maintenance release is now available. This is
libvirt 0.10.2 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-0.10.2.1.tar.gz
Changes in this version:
* qemu: Fix domxml-to-native network model conversion
* parallels: fix build for some older compilers
* documentation: HTML tag fix
* network: fix networkValidate check for default portgroup and vlan
* esx: Update version checks for vSphere 5.1
* Fix detection of Xen sysctl version 9
* selinux: Don't fail RestoreAll if file doesn't have a default label
* storage: don't shadow global 'wait' declaration
* Remove a couple duplicates from AUTHORS.in (cherry picked from commit
2e99fa0385eea0084c520b4a3798a8663fb11b7a)
* storage: Don't do wait loops from VolLookupByPath
* storage: Add timeout for iscsi volume's stable path discovery
* spec: Fix multilib issue with systemtap tapsets
* docs: Fix installation of internals/*.html
* virsh: Fix segfault of snapshot-list
* docs: virsh: clarify behavior of send-key
* daemon: Avoid 'Could not find keytab file' in syslog
* network: don't allow multiple default portgroups
* network: always create dnsmasq hosts and addnhosts files, even if
empty
* network: free/null newDef if network fails to start
* Autogenerate AUTHORS
* build: avoid infinite autogen loop
* selinux: relabel tapfd in qemuPhysIfaceConnect
* network: Set to NULL after virNetworkDefFree()
* selinux: remove unused variables in socket labelling (cherry picked
from commit d37a3a1d6c6508f235965185453602ba310cc66e)
* selinux: fix wrong tapfd relablling
* selinux: Use raw contexts 2
* selinux: add security selinux function to label tapfd
* selinux: Use raw contexts
* network: fix dnsmasq/radvd binding to IPv6 on recent kernels
* qemu: Clear async job when p2p migration fails early
* storage: lvm: lvcreate fails with allocation=0, don't do that
* storage: lvm: Don't overwrite lvcreate errors
* spec: Add runtime requirement for libssh2
* spec: Add support for libssh2 transport
* conf: Fix crash with cleanup
* Properly parse (unsigned) long long
* Correct name of domain/pm/suspend-to-mem in docs (cherry picked from
commit 0ec6aebb6461b3d6ef71322114cf160ae2d3de19)
* storage: Report UUID/name consistently in driver errors
* Change qemuSetSchedularParameters to use AFFECT_CURRENT
* nodeinfo: Fully convert to new virReportError
* Call curl_global_init from virInitialize to avoid thread-safety issues
* fix kvm_pv_eoi with kvmclock
* esx: Disable libcurl's use of signals to fix a segfault
* S390: Buffer too small for large CPU numbers.
* spec: prefer canonical name of util-linux
* docs: fix links in migration.html TOC
* Correct checking of virStrcpyStatic() return value
* build: avoid -Wno-format on new-enough gcc
* qemu: Use proper agent entering function when freezing filesystems
* lxc: Correctly report active cgroups
* build: fix bitmap conversion when !CPU_ALLOC
* Add note about numeric domain names to manpage
* build: default selinuxfs mount point to /sys/fs/selinux
* ARMHF: implement /proc/cpuinfo parsing
* python: return error if PyObject obj is NULL for unwrapper helper
functions
* Fix compilation of legacy xen driver with Xen 4.2
* Fix handling of itanium arch name in QEMU driver
* Fix potential deadlock when agent is closed
* Fix (rare) deadlock in QEMU monitor callbacks
* Don't skip over socket label cleanup
* Don't ignore return value of qemuProcessKill
* Fix deadlock in handling EOF in LXC monitor
* Support Xen sysctl version 9 in Xen 4.2
* build: avoid older gcc warning
* parallels: don't give null pointers to virBitmapEqual
* parallels: fix memory allocation
* Don't use O_TRUNC when opening QEMU logfiles
* Simplify some redundant locking while unref'ing objects
* Remove pointless virLXCProcessMonitorDestroy method
* Convert virLXCMonitor to use virObject
* Move virProcess{Kill,Abort,TranslateStatus} into virprocess.{c,h}
* Move virProcessKill into virprocess.{h,c}
* Rename virCommandTranslateStatus to virProcessTranslateStatus
* Rename virPid{Abort,Wait} to virProcess{Abort,Wait}
* Rename virKillProcess to virProcessKill
* Fix start of containers with custom root filesystem
* Update how to compile with -Werror
* build: fix detection of netcf linked with libnl1
* command: Change virCommandAddEnv so it replaces existing environment
variables. (cherry picked from commit
2b32735af480055e27400068d27364d521071117)
* command: Move environ-adding code to common function virCommandAddEnv.
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
12 years
[libvirt] ANNOUNCE: libvirt 0.9.11.7 maintenance release
by Cole Robinson
libvirt 0.9.11.7 maintenance release is now available. This is
libvirt 0.9.11 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-0.9.11.7.tar.gz
Changes in this version:
* qemu: Fix domxml-to-native network model conversion
* selinux: Don't fail RestoreAll if file doesn't have a default label
* spec: Fix multilib issue with systemtap tapsets
* docs: Fix installation of internals/*.html
* docs: virsh: clarify behavior of send-key
* daemon: Avoid 'Could not find keytab file' in syslog
* storage: lvm: Don't overwrite lvcreate errors
* qemu: Clear async job when p2p migration fails early
* Revert "build: fix compilation without struct ifreq"
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
12 years
[libvirt] [PATCH v2] qemu: Fix domxml-to-native network model conversion
by Cole Robinson
https://bugzilla.redhat.com/show_bug.cgi?id=636832
---
v2:
Don't needlessly reallocate model
src/qemu/qemu_driver.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index feda4d9..7c462a2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5362,6 +5362,8 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
for (i = 0 ; i < def->nnets ; i++) {
virDomainNetDefPtr net = def->nets[i];
int bootIndex = net->info.bootIndex;
+ char *model = net->model;
+
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
int actualType = virDomainNetGetActualType(net);
const char *brname;
@@ -5418,8 +5420,10 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
net->data.ethernet.dev = brname;
net->data.ethernet.ipaddr = ipaddr;
}
+
VIR_FREE(net->virtPortProfile);
net->info.bootIndex = bootIndex;
+ net->model = model;
}
monitor_json = qemuCapsGet(caps, QEMU_CAPS_MONITOR_JSON);
--
1.7.11.7
12 years
[libvirt] [PATCH] build: typo fix for qemu cpu affinity
by Eric Blake
Introduced in commit 0039a32f.
* src/qemu/qemu_process.c (qemuPrepareCpumap): s/covert/convert/
---
Pushing under the trivial rule.
src/qemu/qemu_process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 318875d..3ac5282 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1926,7 +1926,7 @@ qemuPrepareCpumap(struct qemud_driver *driver,
bool result;
if (virBitmapGetBit(nodemask, i, &result) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to covert nodeset to cpuset"));
+ _("Failed to convert nodeset to cpuset"));
virBitmapFree(cpumap);
return NULL;
}
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCHv9 0/9] blockjob: storage migration via block-copy
by Eric Blake
v8 was here:
https://www.redhat.com/archives/libvir-list/2012-October/msg01105.html
A couple of patches were applied independently. Also, this post
clears up some bugs, such as improperly holding the driver lock
or failing to clean up properly on error, as well as some improved
commit messages.
Eric Blake (9):
blockjob: add qemu capabilities related to block jobs
blockjob: react to active block copy
blockjob: return appropriate event and info
blockjob: support pivot operation on cancel
blockjob: make drive-reopen safer
blockjob: implement block copy for qemu
blockjob: allow for existing files in block-copy
blockjob: allow mirroring under SELinux and cgroup
blockjob: relabel entire existing chain
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 12 ++
src/conf/domain_conf.h | 1 +
src/libvirt.c | 7 +-
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 8 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 423 ++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_hotplug.c | 7 +
src/qemu/qemu_migration.c | 5 +
src/qemu/qemu_monitor.c | 56 +++++-
src/qemu/qemu_monitor.h | 14 ++
src/qemu/qemu_monitor_json.c | 96 +++++++++-
src/qemu/qemu_monitor_json.h | 21 ++-
src/qemu/qemu_process.c | 3 +
15 files changed, 645 insertions(+), 12 deletions(-)
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCH] qemu: fix attach/detach of netdevs with matching mac addrs
by Laine Stump
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=862515
which describes inconsistencies in dealing with duplicate mac
addresses on network devices in a domain.
(at any rate, it resolves *almost* everything, and prints out an
informative error message for the one problem that isn't solved, but
has a workaround.)
A synopsis of the problems:
1) you can't do a persistent attach-interface of a device with a mac
address that matches an existing device.
2) you *can* do a live attach-interface of such a device.
3) you *can* directly edit a domain and put in two devices with
matching mac addresses.
4) When running virsh detach-device (live or config), only MAC address
is checked when matching the device to remove, so the first device
with the desired mac address will be removed. This isn't always the
one that's wanted.
5) when running virsh detach-interface (live or config), the only two
items that can be specified to match against are mac address and model
type (virtio, etc) - if multiple netdevs match both of those
attributes, it again just finds the first one added and assumes that
is the only match.
Since it is completely valid to have multiple network devices with the
same MAC address (although it can cause problems in many cases, there
*are* valid use cases), what is needed is:
1) remove the restriction that prohibits doing a persistent add of a
netdev with a duplicate mac address.
2) enhance the backend of virDomainDetachDeviceFlags to check for
something that *is* guaranteed unique (but still work with just mac
address, as long as it yields only a single results.
This patch does three things:
1) removes the check for duplicate mac address during a persistent
netdev attach.
2) unifies the searching for both live and config detach of netdevices
in the subordinate functions of qemuDomainModifyDeviceFlags() to use the
new function virDomainNetFindIdx (which matches mac address and PCI
address if available, checking for duplicates if only mac address was
specified). This function returns -2 if multiple matches are found,
allowing the callers to print out an appropriate message.
Steps 1 & 2 are enough to fully fix the problem when using virsh
attach-device and detach-device (which require an XML description of
the device rather than a bunch of commandline args)
3) modifies the virsh detach-interface command to check for multiple
matches of mac address and show an error message suggesting use of the
detach-device command in cases where there are multiple matching mac
addresses.
Later we should decide how we want to input a PCI address on the virsh
commandline, and enhance detach-interface to take a --address option,
eliminating the need to use detach-device
* src/conf/domain_conf.c
* src/conf/domain_conf.h
* src/libvirt_private.syms
* added new virDomainNetFindIdx function
* removed now unused virDomainNetIndexByMac and
virDomainNetRemoveByMac
* src/qemu/qemu_driver.c
* remove check for duplicate max from qemuDomainAttachDeviceConfig
* use virDomainNetFindIdx/virDomainNetRemove instead
of virDomainNetRemoveByMac in qemuDomainDetachDeviceConfig
* use virDomainNetFindIdx instead of virDomainIndexByMac
in qemuDomainUpdateDeviceConfig
* src/qemu/qemu_hotplug.c
* use virDomainNetFindIdx instead of a homespun loop in
qemuDomainDetachNetDevice.
* tools/virsh-domain.c: modified detach-interface command as described
above
---
src/conf/domain_conf.c | 58 ++++++++++++++++++++++++++++++++++--------------
src/conf/domain_conf.h | 11 +++------
src/libvirt_private.syms | 3 +--
src/qemu/qemu_driver.c | 49 ++++++++++++++++++++++------------------
src/qemu/qemu_hotplug.c | 28 +++++++++++------------
tools/virsh-domain.c | 26 ++++++++++++++++------
6 files changed, 104 insertions(+), 71 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0933c08..51a3b36 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7993,14 +7993,49 @@ int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net)
return 0;
}
-int virDomainNetIndexByMac(virDomainDefPtr def, const virMacAddrPtr mac)
+/* virDomainNetFindIdx: search according to mac address and guest side
+ * PCI address (if specified)
+ *
+ * Return: index of match if unique match found
+ * -1 if not found
+ * -2 if multiple matches
+ */
+int
+virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
{
- int i;
+ int ii, matchidx = -1;
+ bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
- for (i = 0; i < def->nnets; i++)
- if (!virMacAddrCmp(&def->nets[i]->mac, mac))
- return i;
- return -1;
+ for (ii = 0 ; ii < def->nnets ; ii++) {
+ if (virMacAddrCmp(&def->nets[ii]->mac, &net->mac))
+ continue;
+
+ if ((matchidx >= 0) && !PCIAddrSpecified) {
+ /* there were multiple matches on mac address, and no
+ * qualifying guest-side PCI address was given, so we must
+ * fail (NB: a USB address isn't adequate, since it may
+ * specify only vendor and product ID, and there may be
+ * multiples of those.
+ */
+ matchidx = -2; /* indicates "multiple matches" to caller */
+ break;
+ }
+ if (PCIAddrSpecified) {
+ if (virDevicePCIAddressEqual(&def->nets[ii]->info.addr.pci,
+ &net->info.addr.pci)) {
+ /* exit early if the pci address was specified and
+ * it matches, as this guarantees no duplicates.
+ */
+ matchidx = ii;
+ break;
+ }
+ } else {
+ /* no PCI address given, so there may be multiple matches */
+ matchidx = ii;
+ }
+ }
+ return matchidx;
}
virDomainNetDefPtr
@@ -8038,17 +8073,6 @@ virDomainNetRemove(virDomainDefPtr def, size_t i)
return net;
}
-virDomainNetDefPtr
-virDomainNetRemoveByMac(virDomainDefPtr def, const virMacAddrPtr mac)
-{
- int i = virDomainNetIndexByMac(def, mac);
-
- if (i < 0)
- return NULL;
- return virDomainNetRemove(def, i);
-}
-
-
int virDomainControllerInsert(virDomainDefPtr def,
virDomainControllerDefPtr controller)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4151bc2..4c84cb5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2009,12 +2009,10 @@ virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
-int virDomainNetIndexByMac(virDomainDefPtr def, const virMacAddrPtr mac);
+int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
+virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
-virDomainNetDefPtr
-virDomainNetRemove(virDomainDefPtr def, size_t i);
-virDomainNetDefPtr
-virDomainNetRemoveByMac(virDomainDefPtr def, const virMacAddrPtr mac);
+virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
virDomainHostdevDefPtr
@@ -2274,9 +2272,6 @@ VIR_ENUM_DECL(virDomainCpuPlacementMode)
VIR_ENUM_DECL(virDomainStartupPolicy)
-virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def,
- const char *device);
-
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE \
(VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
VIR_CONNECT_LIST_DOMAINS_INACTIVE)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 699c9a3..ce6b9d1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -433,6 +433,7 @@ virDomainMemDumpTypeFromString;
virDomainMemDumpTypeToString;
virDomainNetDefFree;
virDomainNetFind;
+virDomainNetFindIdx;
virDomainNetGetActualBandwidth;
virDomainNetGetActualBridgeName;
virDomainNetGetActualDirectDev;
@@ -441,10 +442,8 @@ virDomainNetGetActualHostdev;
virDomainNetGetActualType;
virDomainNetGetActualVirtPortProfile;
virDomainNetGetActualVlan;
-virDomainNetIndexByMac;
virDomainNetInsert;
virDomainNetRemove;
-virDomainNetRemoveByMac;
virDomainNetTypeToString;
virDomainNostateReasonTypeFromString;
virDomainNostateReasonTypeToString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 254f191..3838c36 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6158,14 +6158,6 @@ qemuDomainAttachDeviceConfig(qemuCapsPtr caps,
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if (virDomainNetIndexByMac(vmdef, &net->mac) >= 0) {
- char macbuf[VIR_MAC_STRING_BUFLEN];
-
- virMacAddrFormat(&net->mac, macbuf);
- virReportError(VIR_ERR_INVALID_ARG,
- _("mac %s already exists"), macbuf);
- return -1;
- }
if (virDomainNetInsert(vmdef, net)) {
virReportOOMError();
return -1;
@@ -6237,11 +6229,12 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
virDomainDeviceDefPtr dev)
{
virDomainDiskDefPtr disk, det_disk;
- virDomainNetDefPtr net, det_net;
+ virDomainNetDefPtr net;
virDomainHostdevDefPtr hostdev, det_hostdev;
virDomainLeaseDefPtr lease, det_lease;
virDomainControllerDefPtr cont, det_cont;
int idx;
+ char mac[VIR_MAC_STRING_BUFLEN];
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
@@ -6256,15 +6249,19 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if (!(det_net = virDomainNetRemoveByMac(vmdef, &net->mac))) {
- char macbuf[VIR_MAC_STRING_BUFLEN];
-
- virMacAddrFormat(&net->mac, macbuf);
- virReportError(VIR_ERR_INVALID_ARG,
- _("no nic of mac %s"), macbuf);
+ idx = virDomainNetFindIdx(vmdef, net);
+ if (idx == -2) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("multiple devices matching mac address %s found"),
+ virMacAddrFormat(&net->mac, mac));
+ return -1;
+ } else if (idx < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("no matching network device was found"));
return -1;
}
- virDomainNetDefFree(det_net);
+ /* this is guaranteed to succeed */
+ virDomainNetDefFree(virDomainNetRemove(vmdef, idx));
break;
case VIR_DOMAIN_DEVICE_HOSTDEV: {
@@ -6319,6 +6316,8 @@ qemuDomainUpdateDeviceConfig(qemuCapsPtr caps,
virDomainDiskDefPtr orig, disk;
virDomainNetDefPtr net;
int pos;
+ char mac[VIR_MAC_STRING_BUFLEN];
+
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
@@ -6356,12 +6355,18 @@ qemuDomainUpdateDeviceConfig(qemuCapsPtr caps,
case VIR_DOMAIN_DEVICE_NET:
net = dev->data.net;
- if ((pos = virDomainNetIndexByMac(vmdef, &net->mac)) < 0) {
- char macbuf[VIR_MAC_STRING_BUFLEN];
-
- virMacAddrFormat(&net->mac, macbuf);
- virReportError(VIR_ERR_INVALID_ARG,
- _("mac %s doesn't exist"), macbuf);
+ pos = virDomainNetFindIdx(vmdef, net);
+ if (pos == -2) {
+ virMacAddrFormat(&net->mac, mac);
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("couldn't find matching device "
+ "with mac address %s"), mac);
+ return -1;
+ } else if (pos < 0) {
+ virMacAddrFormat(&net->mac, mac);
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("couldn't find matching device "
+ "with mac address %s"), mac);
return -1;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7381921..0225654 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2448,30 +2448,28 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
{
- int i, ret = -1;
+ int detachidx, ret = -1;
virDomainNetDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
int vlan;
char *hostnet_name = NULL;
+ char mac[VIR_MAC_STRING_BUFLEN];
virNetDevVPortProfilePtr vport = NULL;
- for (i = 0 ; i < vm->def->nnets ; i++) {
- virDomainNetDefPtr net = vm->def->nets[i];
-
- if (!virMacAddrCmp(&net->mac, &dev->data.net->mac)) {
- detach = net;
- break;
+ detachidx = virDomainNetFindIdx(vm->def, dev->data.net);
+ if (detachidx == -2) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("multiple devices matching mac address %s found"),
+ virMacAddrFormat(&dev->data.net->mac, mac));
+ goto cleanup;
}
- }
-
- if (!detach) {
+ else if (detachidx < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("network device %02x:%02x:%02x:%02x:%02x:%02x not found"),
- dev->data.net->mac.addr[0], dev->data.net->mac.addr[1],
- dev->data.net->mac.addr[2], dev->data.net->mac.addr[3],
- dev->data.net->mac.addr[4], dev->data.net->mac.addr[5]);
+ _("network device %s not found"),
+ virMacAddrFormat(&dev->data.net->mac, mac));
goto cleanup;
}
+ detach = vm->def->nets[detachidx];
if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
ret = qemuDomainDetachThisHostDevice(driver, vm,
@@ -2575,7 +2573,7 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
cleanup:
if (!ret) {
networkReleaseActualDevice(detach);
- virDomainNetRemove(vm->def, i);
+ virDomainNetRemove(vm->def, detachidx);
virDomainNetDefFree(detach);
}
VIR_FREE(hostnet_name);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0906267..0daaeb4 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7692,7 +7692,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj=NULL;
xmlXPathContextPtr ctxt = NULL;
- xmlNodePtr cur = NULL;
+ xmlNodePtr cur = NULL, matchNode = NULL;
xmlBufferPtr xml_buf = NULL;
const char *mac =NULL, *type = NULL;
char *doc;
@@ -7738,10 +7738,12 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (!mac)
+ if (!mac) {
+ matchNode = obj->nodesetval->nodeTab[0];
goto hit;
+ }
- /* search mac */
+ /* multiple possibilities, so search for matching mac */
for (; i < obj->nodesetval->nodeNr; i++) {
cur = obj->nodesetval->nodeTab[i]->children;
while (cur != NULL) {
@@ -7751,14 +7753,24 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
diff_mac = virMacAddrCompare(tmp_mac, mac);
VIR_FREE(tmp_mac);
if (!diff_mac) {
- goto hit;
+ if (matchNode) {
+ /* this is the 2nd match, so it's ambiguous */
+ vshError(ctl, _("Domain has multiple interfaces matching "
+ "mac address %s. You must use detach-device and "
+ "specify the device pci address to remove it."),
+ mac);
+ goto cleanup;
+ }
+ matchNode = obj->nodesetval->nodeTab[i];
}
}
cur = cur->next;
}
}
- vshError(ctl, _("No found interface whose MAC address is %s"), mac);
- goto cleanup;
+ if (!matchNode) {
+ vshError(ctl, _("No found interface whose MAC address is %s"), mac);
+ goto cleanup;
+ }
hit:
xml_buf = xmlBufferCreate();
@@ -7767,7 +7779,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (xmlNodeDump(xml_buf, xml, obj->nodesetval->nodeTab[i], 0, 0) < 0) {
+ if (xmlNodeDump(xml_buf, xml, matchNode, 0, 0) < 0) {
vshError(ctl, "%s", _("Failed to create XML"));
goto cleanup;
}
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCHv2] cpustat: fix regression when cpus are offline
by Eric Blake
It turns out that the cpuacct results properly account for offline
cpus, and always returns results for every possible cpu, not just
the online ones. So there is no need to check the map of online
cpus in the first place, merely only a need to know the maximum
possible cpu. Meanwhile, virNodeGetCPUBitmap had a subtle change
from returning the maximum id to instead returning the width of
the bitmap (one larger than the maximum id) in commit 2f4c5338,
which made this code encounter some off-by-one logic leading to
bad error messages when a cpu was offline:
$ virsh cpu-stats dom
error: Failed to virDomainGetCPUStats()
error: An error occurred, but the cause is unknown
Cleaning this up unraveled a chain of other unused variables.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Drop
pointless check for cpumap changes, and use correct number of
cpus. Simplify signature.
(qemuDomainGetCPUStats): Adjust caller.
* src/nodeinfo.h (nodeGetCPUCount): New prototype.
(nodeGetCPUBitmap): Drop unused parameter.
* src/nodeinfo.c (nodeGetCPUBitmap): Likewise.
(nodeGetCPUMap): Adjust caller.
(nodeGetCPUCount): New function.
* src/libvirt_private.syms (nodeinfo.h): Export it.
---
v2: add new function for determining just host cpu count, and
do even more cleanups based on unused variables
src/libvirt_private.syms | 1 +
src/nodeinfo.c | 30 +++++++++++++++++++++++-------
src/nodeinfo.h | 4 ++--
src/qemu/qemu_driver.c | 39 ++++++++-------------------------------
4 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 80bdf99..f350493 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -908,6 +908,7 @@ virNodeDeviceObjUnlock;
# nodeinfo.h
nodeCapsInitNUMA;
nodeGetCPUBitmap;
+nodeGetCPUCount;
nodeGetCPUMap;
nodeGetCPUStats;
nodeGetCellsFreeMemory;
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 8b494df..b0be3ed 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -949,9 +949,24 @@ int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
#endif
}
+int
+nodeGetCPUCount(void)
+{
+#ifdef __linux__
+ /* XXX should we also work on older kernels, like RHEL5, that lack
+ * cpu/present and cpu/online files? Those kernels also lack cpu
+ * hotplugging, so it would be a matter of finding the largest
+ * cpu/cpuNN directory, and returning NN + 1 */
+ return linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present");
+#else
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("host cpu counting not implemented on this platform"));
+ return NULL;
+#endif
+}
+
virBitmapPtr
-nodeGetCPUBitmap(virConnectPtr conn ATTRIBUTE_UNUSED,
- int *max_id ATTRIBUTE_UNUSED)
+nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED)
{
#ifdef __linux__
virBitmapPtr cpumap;
@@ -1249,10 +1264,11 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
#endif
}
-int nodeGetCPUMap(virConnectPtr conn,
- unsigned char **cpumap,
- unsigned int *online,
- unsigned int flags)
+int
+nodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
+ unsigned char **cpumap,
+ unsigned int *online,
+ unsigned int flags)
{
virBitmapPtr cpus = NULL;
int maxpresent;
@@ -1261,7 +1277,7 @@ int nodeGetCPUMap(virConnectPtr conn,
virCheckFlags(0, -1);
- if (!(cpus = nodeGetCPUBitmap(conn, &maxpresent)))
+ if (!(cpus = nodeGetCPUBitmap(&maxpresent)))
goto cleanup;
if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index 44aa55d..350f3c3 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -46,8 +46,8 @@ int nodeGetCellsFreeMemory(virConnectPtr conn,
int maxCells);
unsigned long long nodeGetFreeMemory(virConnectPtr conn);
-virBitmapPtr nodeGetCPUBitmap(virConnectPtr conn,
- int *max_id);
+virBitmapPtr nodeGetCPUBitmap(int *max_id);
+int nodeGetCPUCount(void);
int nodeGetMemoryParameters(virConnectPtr conn,
virTypedParameterPtr params,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 18be7d9..8cb92b6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13588,16 +13588,13 @@ cleanup:
}
static int
-qemuDomainGetPercpuStats(virDomainPtr domain,
- virDomainObjPtr vm,
+qemuDomainGetPercpuStats(virDomainObjPtr vm,
virCgroupPtr group,
virTypedParameterPtr params,
unsigned int nparams,
int start_cpu,
unsigned int ncpus)
{
- virBitmapPtr map = NULL;
- virBitmapPtr map2 = NULL;
int rv = -1;
int i, id, max_id;
char *pos;
@@ -13609,19 +13606,18 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
virTypedParameterPtr ent;
int param_idx;
unsigned long long cpu_time;
- bool result;
/* return the number of supported params */
if (nparams == 0 && ncpus != 0)
return QEMU_NB_PER_CPU_STAT_PARAM;
- /* To parse account file, we need bitmap of online cpus. */
- map = nodeGetCPUBitmap(domain->conn, &max_id);
- if (!map)
+ /* To parse account file, we need to know how many cpus are present. */
+ max_id = nodeGetCPUCount();
+ if (max_id < 0)
return rv;
if (ncpus == 0) { /* returns max cpu ID */
- rv = max_id + 1;
+ rv = max_id;
goto cleanup;
}
@@ -13648,11 +13644,7 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
id = start_cpu + ncpus - 1;
for (i = 0; i <= id; i++) {
- if (virBitmapGetBit(map, i, &result) < 0)
- goto cleanup;
- if (!result) {
- cpu_time = 0;
- } else if (virStrToLong_ull(pos, &pos, 10, &cpu_time) < 0) {
+ if (virStrToLong_ull(pos, &pos, 10, &cpu_time) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpuacct parse error"));
goto cleanup;
@@ -13680,22 +13672,9 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
if (getSumVcpuPercpuStats(group, priv->nvcpupids, sum_cpu_time, n) < 0)
goto cleanup;
- /* Check that the mapping of online cpus didn't change mid-parse. */
- map2 = nodeGetCPUBitmap(domain->conn, &max_id);
- if (!map2 || !virBitmapEqual(map, map2)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("the set of online cpus changed while reading"));
- goto cleanup;
- }
-
sum_cpu_pos = sum_cpu_time;
for (i = 0; i <= id; i++) {
- if (virBitmapGetBit(map, i, &result) < 0)
- goto cleanup;
- if (!result)
- cpu_time = 0;
- else
- cpu_time = *(sum_cpu_pos++);
+ cpu_time = *(sum_cpu_pos++);
if (i < start_cpu)
continue;
if (virTypedParameterAssign(¶ms[(i - start_cpu) * nparams +
@@ -13710,8 +13689,6 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
cleanup:
VIR_FREE(sum_cpu_time);
VIR_FREE(buf);
- virBitmapFree(map);
- virBitmapFree(map2);
return rv;
}
@@ -13763,7 +13740,7 @@ qemuDomainGetCPUStats(virDomainPtr domain,
if (start_cpu == -1)
ret = qemuDomainGetTotalcpuStats(group, params, nparams);
else
- ret = qemuDomainGetPercpuStats(domain, vm, group, params, nparams,
+ ret = qemuDomainGetPercpuStats(vm, group, params, nparams,
start_cpu, ncpus);
cleanup:
virCgroupFree(&group);
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCH] build: fix type-punning bug
by Eric Blake
With older gcc and 64-bit size_t, the compiler issues a real warning:
rpc/virnetserverservice.c:277: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
Introduced in commit 0cc79255. Depending on machine endianness,
this warning represents a real bug that could mis-interpret the
value by a factor of 2^32. I don't know why newer gcc didn't
bother to warn.
* src/rpc/virnetserverservice.c
(virNetServerServiceNewPostExecRestart): Use temporary instead.
---
src/rpc/virnetserverservice.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index 8ac523c..31a9424 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -1,7 +1,7 @@
/*
* virnetserverservice.c: generic network RPC server service
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -274,11 +274,12 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
goto error;
}
if (virJSONValueObjectGetNumberUint(object, "nrequests_client_max",
- (unsigned int *)&svc->nrequests_client_max) < 0) {
+ &n) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing nrequests_client_max field in JSON state document"));
goto error;
}
+ svc->nrequests_client_max = n;
if (!(socks = virJSONValueObjectGet(object, "socks"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
1.7.11.7
12 years, 1 month