[libvirt] [PATCH 1/2] Move qemuGetDHCPInterfaces to separate file
by Guido Günther
so we can use it from the LXC driver as well.
---
I couldn't find a nice place to add this so I went for a separate file. I'm
happy to move this elsewhere.
Cheers,
-- Guido
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/libvirt_private.syms | 4 ++
src/qemu/qemu_driver.c | 104 +----------------------------------
src/util/virdhcpinterfaces.c | 127 +++++++++++++++++++++++++++++++++++++++++++
src/util/virdhcpinterfaces.h | 34 ++++++++++++
6 files changed, 169 insertions(+), 102 deletions(-)
create mode 100644 src/util/virdhcpinterfaces.c
create mode 100644 src/util/virdhcpinterfaces.h
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 82e8d3e..64eaa9d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -186,6 +186,7 @@ src/util/vircommand.c
src/util/virconf.c
src/util/vircrypto.c
src/util/virdbus.c
+src/util/virdhcpinterfaces.c
src/util/virdnsmasq.c
src/util/virerror.c
src/util/virerror.h
diff --git a/src/Makefile.am b/src/Makefile.am
index a4aef0f..bddfd21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -104,6 +104,7 @@ UTIL_SOURCES = \
util/virconf.c util/virconf.h \
util/vircrypto.c util/vircrypto.h \
util/virdbus.c util/virdbus.h util/virdbuspriv.h \
+ util/virdhcpinterfaces.c util/virdhcpinterfaces.h \
util/virdnsmasq.c util/virdnsmasq.h \
util/virebtables.c util/virebtables.h \
util/virendian.h \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3d0ec9d..ea3e83c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1377,6 +1377,10 @@ virDBusMessageRead;
virDBusSetSharedBus;
+# util/virdhcpinterfaces.h
+virGetDHCPInterfaces;
+
+
# util/virdnsmasq.h
dnsmasqAddDhcpHost;
dnsmasqAddHost;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index abcdbe6..fe1cb6d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -101,6 +101,7 @@
#include "virnuma.h"
#include "dirname.h"
#include "network/bridge_driver.h"
+#include "virdhcpinterfaces.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -173,10 +174,6 @@ static int qemuOpenFileAs(uid_t fallback_uid, gid_t fallback_gid,
const char *path, int oflags,
bool *needUnlink, bool *bypassSecurityDriver);
-static int qemuGetDHCPInterfaces(virDomainPtr dom,
- virDomainObjPtr vm,
- virDomainInterfacePtr **ifaces);
-
virQEMUDriverPtr qemu_driver = NULL;
@@ -19794,7 +19791,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom,
switch (source) {
case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE:
- ret = qemuGetDHCPInterfaces(dom, vm, ifaces);
+ ret = virGetDHCPInterfaces(dom, vm, ifaces);
break;
case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT:
@@ -19825,103 +19822,6 @@ qemuDomainInterfaceAddresses(virDomainPtr dom,
return ret;
}
-static int
-qemuGetDHCPInterfaces(virDomainPtr dom,
- virDomainObjPtr vm,
- virDomainInterfacePtr **ifaces)
-{
- int rv = -1;
- int n_leases = 0;
- size_t i, j;
- size_t ifaces_count = 0;
- virNetworkPtr network = NULL;
- char macaddr[VIR_MAC_STRING_BUFLEN];
- virDomainInterfacePtr iface = NULL;
- virNetworkDHCPLeasePtr *leases = NULL;
- virDomainInterfacePtr *ifaces_ret = NULL;
-
- if (!dom->conn->networkDriver ||
- !dom->conn->networkDriver->networkGetDHCPLeases) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Network driver does not support DHCP lease query"));
- return -1;
- }
-
- for (i = 0; i < vm->def->nnets; i++) {
- if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
- continue;
-
- virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
- virObjectUnref(network);
- network = virNetworkLookupByName(dom->conn,
- vm->def->nets[i]->data.network.name);
-
- if ((n_leases = virNetworkGetDHCPLeases(network, macaddr,
- &leases, 0)) < 0)
- goto error;
-
- if (n_leases) {
- if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
- goto error;
-
- if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
- goto error;
-
- iface = ifaces_ret[ifaces_count - 1];
- /* Assuming each lease corresponds to a separate IP */
- iface->naddrs = n_leases;
-
- if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
- goto error;
-
- if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
- goto cleanup;
-
- if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
- goto cleanup;
- }
-
- for (j = 0; j < n_leases; j++) {
- virNetworkDHCPLeasePtr lease = leases[j];
- virDomainIPAddressPtr ip_addr = &iface->addrs[j];
-
- if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
- goto cleanup;
-
- ip_addr->type = lease->type;
- ip_addr->prefix = lease->prefix;
- }
-
- for (j = 0; j < n_leases; j++)
- virNetworkDHCPLeaseFree(leases[j]);
-
- VIR_FREE(leases);
- }
-
- *ifaces = ifaces_ret;
- ifaces_ret = NULL;
- rv = ifaces_count;
-
- cleanup:
- virObjectUnref(network);
- if (leases) {
- for (i = 0; i < n_leases; i++)
- virNetworkDHCPLeaseFree(leases[i]);
- }
- VIR_FREE(leases);
-
- return rv;
-
- error:
- if (ifaces_ret) {
- for (i = 0; i < ifaces_count; i++)
- virDomainInterfaceFree(ifaces_ret[i]);
- }
- VIR_FREE(ifaces_ret);
-
- goto cleanup;
-}
-
static int
qemuDomainSetUserPassword(virDomainPtr dom,
diff --git a/src/util/virdhcpinterfaces.c b/src/util/virdhcpinterfaces.c
new file mode 100644
index 0000000..80135f7
--- /dev/null
+++ b/src/util/virdhcpinterfaces.c
@@ -0,0 +1,127 @@
+/*
+ * virdhcpinterfaces.c: get a domains dhcp managed interfaces
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "virdhcpinterfaces.h"
+#include "viralloc.h"
+#include "virstring.h"
+#include "datatypes.h"
+
+#define VIR_FROM_THIS VIR_FROM_AUDIT
+
+int
+virGetDHCPInterfaces(virDomainPtr dom,
+ virDomainObjPtr vm,
+ virDomainInterfacePtr **ifaces)
+{
+ int rv = -1;
+ int n_leases = 0;
+ size_t i, j;
+ size_t ifaces_count = 0;
+ virNetworkPtr network = NULL;
+ char macaddr[VIR_MAC_STRING_BUFLEN];
+ virDomainInterfacePtr iface = NULL;
+ virNetworkDHCPLeasePtr *leases = NULL;
+ virDomainInterfacePtr *ifaces_ret = NULL;
+
+ if (!dom->conn->networkDriver ||
+ !dom->conn->networkDriver->networkGetDHCPLeases) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Network driver does not support DHCP lease query"));
+ return -1;
+ }
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
+ continue;
+
+ virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
+ virObjectUnref(network);
+ network = virNetworkLookupByName(dom->conn,
+ vm->def->nets[i]->data.network.name);
+
+ if ((n_leases = virNetworkGetDHCPLeases(network, macaddr,
+ &leases, 0)) < 0)
+ goto error;
+
+ if (n_leases) {
+ if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
+ goto error;
+
+ if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
+ goto error;
+
+ iface = ifaces_ret[ifaces_count - 1];
+ /* Assuming each lease corresponds to a separate IP */
+ iface->naddrs = n_leases;
+
+ if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
+ goto error;
+
+ if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
+ goto cleanup;
+ }
+
+ for (j = 0; j < n_leases; j++) {
+ virNetworkDHCPLeasePtr lease = leases[j];
+ virDomainIPAddressPtr ip_addr = &iface->addrs[j];
+
+ if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
+ goto cleanup;
+
+ ip_addr->type = lease->type;
+ ip_addr->prefix = lease->prefix;
+ }
+
+ for (j = 0; j < n_leases; j++)
+ virNetworkDHCPLeaseFree(leases[j]);
+
+ VIR_FREE(leases);
+ }
+
+ *ifaces = ifaces_ret;
+ ifaces_ret = NULL;
+ rv = ifaces_count;
+
+ cleanup:
+ virObjectUnref(network);
+ if (leases) {
+ for (i = 0; i < n_leases; i++)
+ virNetworkDHCPLeaseFree(leases[i]);
+ }
+ VIR_FREE(leases);
+
+ return rv;
+
+ error:
+ if (ifaces_ret) {
+ for (i = 0; i < ifaces_count; i++)
+ virDomainInterfaceFree(ifaces_ret[i]);
+ }
+ VIR_FREE(ifaces_ret);
+
+ goto cleanup;
+}
diff --git a/src/util/virdhcpinterfaces.h b/src/util/virdhcpinterfaces.h
new file mode 100644
index 0000000..c7acb8f
--- /dev/null
+++ b/src/util/virdhcpinterfaces.h
@@ -0,0 +1,34 @@
+/*
+ * virdhcpinterfaces.h: get a domains dhcp managed interfaces
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#ifndef __VIR_DHCP_INTERFACES_H__
+# define __VIR_DHCP_INTERFACES_H__
+
+# include "internal.h"
+# include "virdomainobjlist.h"
+
+int
+virGetDHCPInterfaces(virDomainPtr dom,
+ virDomainObjPtr vm,
+ virDomainInterfacePtr **ifaces);
+
+#endif /* __VIR_DHCP_INTERFACES_H__ */
--
2.7.0.rc3
8 years, 9 months
[libvirt] [PATCH v2 00/21] vcpu info storage refactors - part 2
by Peter Krempa
Some of patches were pushed. The rest fixes most of the feedback that made
sense that was against v1.
Peter Krempa (21):
cgroup: Clean up virCgroupGetPercpuStats
conf: Add helper to retrieve bitmap of active vcpus for a definition
cgroup: Prepare for sparse vCPU topologies in virCgroupGetPercpuStats
qemu: cpu hotplug: Set vcpu state directly in the new structure
qemu: Move and rename qemuProcessDetectVcpuPIDs to
qemuDomainDetectVcpuPids
qemu: domain: Prepare qemuDomainDetectVcpuPids for reuse
qemu: Reuse qemuDomainDetectVcpuPids in cpu hot(un)plug
conf: Don't copy def->cpumask into cpu pinning info
conf: Split out logic to determine whether cpupin was provided
conf: Store cpu pinning data in def->vcpus
conf: remove unused cpu pinning helpers and data structures
conf: Extract code that formats <cputune>
util: bitmap: Introduce bitmap subtraction
conf: Add helper to return a bitmap of active iothread ids
conf: Extract code for parsing thread resource scheduler info
conf: Don't store vcpusched orthogonally to other vcpu info
conf: Fix how iothread scheduler info is stored
qemu: vcpu: Aggregate code to set vCPU tuning
qemu: vcpu: Reuse qemuProcessSetupVcpu in vcpu hotplug
qemu: iothread: Aggregate code to set IOTrhead tuning
qemu: iothread: Reuse qemuProcessSetupIOThread in iothread hotplug
src/conf/domain_conf.c | 940 +++++++++++----------
src/conf/domain_conf.h | 45 +-
src/libvirt_private.syms | 10 +-
src/libxl/libxl_domain.c | 20 +-
src/libxl/libxl_driver.c | 41 +-
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_cgroup.c | 195 -----
src/qemu/qemu_cgroup.h | 2 -
src/qemu/qemu_domain.c | 84 ++
src/qemu/qemu_domain.h | 2 +
src/qemu/qemu_driver.c | 405 +++------
src/qemu/qemu_process.c | 478 ++++++-----
src/qemu/qemu_process.h | 6 +
src/test/test_driver.c | 45 +-
src/util/virbitmap.c | 21 +
src/util/virbitmap.h | 3 +
src/util/vircgroup.c | 74 +-
src/util/vircgroup.h | 3 +-
src/vz/vz_sdk.c | 4 +-
.../qemuxml2xmlout-cputune-iothreadsched.xml | 3 +-
tests/virbitmaptest.c | 55 ++
tests/vircgrouptest.c | 2 +-
22 files changed, 1148 insertions(+), 1292 deletions(-)
--
2.6.2
8 years, 9 months
[libvirt] [PATCH v4] qemu: Connect to guest agent iff needed
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1293351
Since we already have virtio channel events, we know when guest
agent within guest has (dis-)connected. Instead of us blindly
connecting to a socket that no one is listening to, we can just
follow what qemu-ga does. This has a nice benefit that we don't
need to 'guest-ping' the agent just to timeout and find out
nobody is listening.
The way that this commit is implemented:
- don't connect in qemuProcessStart directly, defer that to event
callback (which already follows the agent).
- after migration is settled, before we resume vCPUs, ask qemu
whether somebody is listening on the socket and if so, connect
to it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
diff to v3:
-Move cap detection into qemuConnectAgent
src/qemu/qemu_driver.c | 13 ++++++++++++-
src/qemu/qemu_migration.c | 12 ++++++++++++
src/qemu/qemu_process.c | 24 ++++++++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8ccf68b..3751ba6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6650,12 +6650,13 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
bool start_paused,
qemuDomainAsyncJob asyncJob)
{
- int ret = -1;
+ int rc, ret = -1;
virObjectEventPtr event;
int intermediatefd = -1;
virCommandPtr cmd = NULL;
char *errbuf = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ qemuDomainObjPrivatePtr priv = vm->privateData;
if ((header->version == 2) &&
(header->compressed != QEMU_SAVE_FORMAT_RAW)) {
@@ -6710,6 +6711,16 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
goto cleanup;
}
+ if ((rc = qemuConnectAgent(driver, vm)) < 0) {
+ if (rc == -2)
+ goto cleanup;
+
+ VIR_WARN("Cannot connect to QEMU guest agent for %s",
+ vm->def->name);
+ virResetLastError();
+ priv->agentError = true;
+ }
+
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
VIR_DOMAIN_EVENT_STARTED_RESTORED);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 51e7125..9678adf 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5795,6 +5795,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
unsigned short port;
unsigned long long timeReceived = 0;
virObjectEventPtr event;
+ int rc;
VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
@@ -5863,6 +5864,17 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
if (qemuMigrationStopNBDServer(driver, vm, mig) < 0)
goto endjob;
+ if ((rc = qemuConnectAgent(driver, vm)) < 0) {
+ if (rc == -2)
+ goto endjob;
+
+ VIR_WARN("Cannot connect to QEMU guest agent for %s",
+ vm->def->name);
+ virResetLastError();
+ priv->agentError = true;
+ }
+
+
if (flags & VIR_MIGRATE_PERSIST_DEST) {
if (qemuMigrationPersist(driver, vm, mig, !v3proto) < 0) {
/* Hmpf. Migration was successful, but making it persistent
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 05cbda2..e1a25dd 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -77,6 +77,10 @@
VIR_LOG_INIT("qemu.qemu_process");
+static int
+qemuProcessReconnectRefreshChannelVirtioState(virQEMUDriverPtr driver,
+ virDomainObjPtr vm);
+
/**
* qemuProcessRemoveDomainStatus
*
@@ -208,6 +212,26 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
if (!config)
return 0;
+ if (priv->agent)
+ return 0;
+
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPORT_CHANGE) &&
+ config->state != VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
+ /* So qemu is capable of sending us event whenever guest agent
+ * (dis-)connects. And we reflect its state in config->state. Well,
+ * nearly. It may happen that what we think about the guest agent state
+ * is not accurate, e.g. right after migration. Ask qemu to be sure. */
+
+ if (qemuProcessReconnectRefreshChannelVirtioState(driver, vm) < 0)
+ goto cleanup;
+
+ /* Now we are sure about the channel state. */
+ if (config->state != VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
+ VIR_DEBUG("Deferring connecting to guest agent");
+ return 0;
+ }
+ }
+
if (virSecurityManagerSetDaemonSocketLabel(driver->securityManager,
vm->def) < 0) {
VIR_ERROR(_("Failed to set security context for agent for %s"),
--
2.4.10
8 years, 9 months
[libvirt] oVirt considers using macTableManager='libvirt'
by Ido Barkan
Hi guys,
We, at oVirt, are considring using the automatic bridge management
feature of libvirt for our hosts
(macTableManager='libvirt').
I could find any discussion in the mailing list archives about the
motivation for this feature.
(was there?). If there wasn't I would like to start a new one, about
the possible trade offs it would
have in oVirt.
Specifically I have a few questions:
1) The obvious performance motivation is clear: considering N hosts
with M vms each connected to
the same LAN, the first packet to any unknown yet host will flood
all the vms in all N bridges.
-- was there any other motivation that I do not understand
(apart from slightly better security?
2) oVirt uses TC for port mirroring, in case this is requested by
users, to mirror traffic from a chosen
bridge to a chosen NIC in the host. I could not understand if
macTableManager will interfere
with it, or not.
3) Are there any drawbacks to enabling this feature?
4) We aim for rhel7.2. Will the feature be supported (or partially
supported) for kernels older then
3.17? And if so, in what way?
5) oVirt currently builds its own bridges and tell libvirt about them.
Does that have any affect on the
functionality of that feature?
6) are there any plans to support OVS for this feature in the future?
--
Thanks,
Ido Barkan
8 years, 9 months
[libvirt] [PATCH v2 0/6] Some logical pool/volume changes
by John Ferlan
v1: http://www.redhat.com/archives/libvir-list/2016-January/msg01023.html
Differences to v1:
Patch 1 is the former patch 2 with the following adjuments:
- Change helper name to be virStorageBackendLogicalParseVolExtents
- Include all 'extent' parsing needs - including fetch/parse of 'stripes'
to determine 'nextents' value, allocation of vol->source.extents,
parse of groups[6] to be 'length', parse of groups[7] to be 'size'
Patch 2 is new, but replaces some of the concepts from patch 3:
- I rototilled the virStorageBackendLogicalParseVolExtents to remove
the unnecessary trip through regex/regcomp.
- Used virStringSplitCount instread and then parse the resultant string.
- Removed the need for the 'stripes' fetch since it really wasn't doing
what it was supposed to.
- I adjusted the virstringtest to exhibit what is being parsed (it can
be removed if you think that's excessive).
Patches 3-5 are new
- These could be combined. I left them separate to show the process...
- Essentially adding a new "source" field to be used to display in
the vol-dumpxml output
Patch 6 is part of the old patch 4:
- Since the old patch 3 isn't necessary - it's essentially gone. This
just takes the patch 4 concept of changing the regex, but also applies
it to the current code.
John Ferlan (6):
logical: Create helper virStorageBackendLogicalParseVolExtents
logical: Fix parsing of the 'devices' field lvs output
logical: Search for a segtype of "thin" and mark lv as sparse
vol: Add thin_pool to _virStorageVolSource
logical: Add capability to get the thin pool name
logical: Display thin lv's found in a libvirt managed volume group
docs/formatstorage.html.in | 9 +-
src/conf/storage_conf.c | 5 +
src/conf/storage_conf.h | 1 +
src/storage/storage_backend_logical.c | 221 ++++++++++++++++------------------
tests/virstringtest.c | 11 ++
5 files changed, 127 insertions(+), 120 deletions(-)
--
2.5.0
8 years, 9 months
[libvirt] [PATCH v3 0/4] virshBlockJobWait improvements
by Michael Chapman
v2 discussion at:
http://www.redhat.com/archives/libvir-list/2016-January/msg01063.html
As requested I've split this into separate commits. All of the comment
nitpicks have been applied.
With regards to using "break" or "goto cleanup" to exit the loop, I decided
to use "goto" on all the error cases and "break" everywhere else. I had
noticed another bug where the SIGINT signal action wasn't reset if the
virTimeMillisNow() call failed; that's fixed in patch 3 in this series.
Michael Chapman (4):
virsh: avoid unnecessary progress updates
virsh: be consistent with style of loop exit
virsh: ensure SIGINT action is reset on all errors
virsh: improve waiting for block job readiness
tools/virsh-domain.c | 65 ++++++++++++++++++++++++++++++----------------------
1 file changed, 37 insertions(+), 28 deletions(-)
--
2.4.3
8 years, 9 months
[libvirt] [PATCH] qemu: Mark some functions as static
by Cole Robinson
---
src/qemu/qemu_command.c | 16 +++++++++++++---
src/qemu/qemu_command.h | 11 -----------
src/qemu/qemu_process.h | 2 --
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5d3ab3a..8943270 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1775,6 +1775,16 @@ qemuDomainPCIBusFullyReserved(virDomainPCIAddressBusPtr bus)
}
+static int
+qemuAssignDevicePCISlots(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps,
+ virDomainPCIAddressSetPtr addrs);
+static int
+qemuDomainAssignPCIAddresses(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps,
+ virDomainObjPtr obj);
+
+
int qemuDomainAssignAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainObjPtr obj)
@@ -1801,7 +1811,7 @@ int qemuDomainAssignAddresses(virDomainDefPtr def,
}
-virDomainPCIAddressSetPtr
+static virDomainPCIAddressSetPtr
qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
unsigned int nbuses,
bool dryRun)
@@ -2238,7 +2248,7 @@ qemuValidateDevicePCISlotsChipsets(virDomainDefPtr def,
return 0;
}
-int
+static int
qemuDomainAssignPCIAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainObjPtr obj)
@@ -2451,7 +2461,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
* function must only try to reserve addresses if info.type == NONE and
* skip over info.type == PCI
*/
-int
+static int
qemuAssignDevicePCISlots(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainPCIAddressSetPtr addrs)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index a96e57d..53bfda5 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -274,17 +274,6 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
const char *devstr);
-int qemuDomainAssignPCIAddresses(virDomainDefPtr def,
- virQEMUCapsPtr qemuCaps,
- virDomainObjPtr obj);
-virDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
- unsigned int nbuses,
- bool dryRun);
-
-int qemuAssignDevicePCISlots(virDomainDefPtr def,
- virQEMUCapsPtr qemuCaps,
- virDomainPCIAddressSetPtr addrs);
-
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx);
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index c674111..cb5cee1 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -42,8 +42,6 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
void qemuProcessAutostartAll(virQEMUDriverPtr driver);
void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
-int qemuProcessAssignPCIAddresses(virDomainDefPtr def);
-
typedef struct _qemuProcessIncomingDef qemuProcessIncomingDef;
typedef qemuProcessIncomingDef *qemuProcessIncomingDefPtr;
struct _qemuProcessIncomingDef {
--
2.5.0
8 years, 9 months
[libvirt] [PATCH] qemu: Align dump options for watchdog and on_crash events
by Boris Fiuczynski
Having on_crash set to either coredump-destroy or coredump-restart
creates core dumps with option memory-only in the directory specified
by auto_dump_path. When a watchdog is triggered with the action dump
the core dump is also placed into the directory specified by auto_dump_path
but is created without the option memory-only.
This patch sets the option memory-only also for core dumps created by the
watchdog event.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f429832..88ecf48 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3894,7 +3894,7 @@ static void processWatchdogEvent(virQEMUDriverPtr driver, virDomainObjPtr vm, in
case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
{
char *dumpfile;
- unsigned int flags = 0;
+ unsigned int flags = VIR_DUMP_MEMORY_ONLY;
if (virAsprintf(&dumpfile, "%s/%s-%u",
cfg->autoDumpPath,
--
2.3.0
8 years, 9 months
[libvirt] [PATCH v2] qemu: return -1 on error paths in qemuDomainSaveImageStartVM
by Nikolay Shirokovskiy
Error paths after sending the event that domain is started written as if ret = -1
which is set at the beginning of the function. It's common idioma to keep 'ret'
equal to -1 until the end of function where it is set to 0. But here we use ret
to keep result of restore operation too and thus breaks the idioma and its users :)
Let's use different variable to hold restore result.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/qemu/qemu_driver.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 351e529..ced105b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6732,6 +6732,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
qemuDomainAsyncJob asyncJob)
{
int ret = -1;
+ bool restored;
virObjectEventPtr event;
int intermediatefd = -1;
virCommandPtr cmd = NULL;
@@ -6758,13 +6759,13 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
}
/* Set the migration source and start it up. */
- ret = qemuProcessStart(conn, driver, vm, asyncJob,
- "stdio", *fd, path, NULL,
- VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
- VIR_QEMU_PROCESS_START_PAUSED);
+ restored = qemuProcessStart(conn, driver, vm, asyncJob,
+ "stdio", *fd, path, NULL,
+ VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
+ VIR_QEMU_PROCESS_START_PAUSED) >= 0;
if (intermediatefd != -1) {
- if (ret < 0) {
+ if (!restored) {
/* if there was an error setting up qemu, the intermediate
* process will wait forever to write to stdout, so we
* must manually kill it.
@@ -6775,7 +6776,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
if (virCommandWait(cmd, NULL) < 0) {
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
- ret = -1;
+ restored = false;
}
VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf));
}
@@ -6783,18 +6784,16 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
if (VIR_CLOSE(*fd) < 0) {
virReportSystemError(errno, _("cannot close file: %s"), path);
- ret = -1;
+ restored = false;
}
- if (ret < 0) {
- virDomainAuditStart(vm, "restored", false);
+ virDomainAuditStart(vm, "restored", restored);
+ if (!restored)
goto cleanup;
- }
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
VIR_DOMAIN_EVENT_STARTED_RESTORED);
- virDomainAuditStart(vm, "restored", true);
qemuDomainEventQueue(driver, event);
--
1.8.3.1
8 years, 9 months
[libvirt] [libvirt-perl][PATCH] Add VIR_STORAGE_VOL_WIPE_ALG_TRIM constant
by Michal Privoznik
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Changes | 1 +
Virt.xs | 1 +
lib/Sys/Virt/StorageVol.pm | 4 ++++
3 files changed, 6 insertions(+)
diff --git a/Changes b/Changes
index cfcc640..cb57a4d 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@ Revision history for perl module Sys::Virt
1.3.2 2016-02-00
+ - Add VIR_STORAGE_VOL_WIPE_ALG_TRIM constant
- Add VIR_FROM_XENXL constant
- Add VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION event
handling callback
diff --git a/Virt.xs b/Virt.xs
index e47d52e..06111b4 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -8187,6 +8187,7 @@ BOOT:
REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7, WIPE_ALG_PFITZNER7);
REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33, WIPE_ALG_PFITZNER33);
REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_RANDOM, WIPE_ALG_RANDOM);
+ REGISTER_CONSTANT(VIR_STORAGE_VOL_WIPE_ALG_TRIM, WIPE_ALG_TRIM);
REGISTER_CONSTANT(VIR_STORAGE_VOL_RESIZE_ALLOCATE, RESIZE_ALLOCATE);
REGISTER_CONSTANT(VIR_STORAGE_VOL_RESIZE_DELTA, RESIZE_DELTA);
diff --git a/lib/Sys/Virt/StorageVol.pm b/lib/Sys/Virt/StorageVol.pm
index 84ba4e0..461a9fe 100644
--- a/lib/Sys/Virt/StorageVol.pm
+++ b/lib/Sys/Virt/StorageVol.pm
@@ -260,6 +260,10 @@ Cryptography" (1996)
1-pass, all zeroes
+=item Sys::Virt::StorageVol::WIPE_ALG_TRIM
+
+1-pass, trim all data on the volume by using TRIM or DISCARD
+
=back
VOLUME RESIZE CONSTANTS
--
2.4.10
8 years, 9 months