[libvirt] [PATCH v2] virsh-edit: Make force editing usable
by Martin Kletzander
When editing a domain with 'virsh edit' and failing validation, the
usual message pops up:
Failed. Try again? [y,n,f,?]:
Turning of validation can be ussable, mainly for testing (but other
purposes too), so this patch adds support for relaxing definition in
virsh-edit and makes 'virsh edit <domain>' more usable.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2:
- make a special case 'v' for turning off validation
tools/virsh-domain.c | 6 ++++++
tools/virsh-edit.c | 21 +++++++++++++++++++--
tools/virsh.c | 28 +++++++++++++++++++++-------
tools/virsh.h | 4 ++--
4 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2506b89..b4761c6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11265,7 +11265,13 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
} while (0)
#define EDIT_DEFINE \
(dom_edited = vshDomainDefine(ctl->conn, doc_edited, define_flags))
+#define EDIT_RELAX \
+ do { \
+ define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE; \
+ } while (0);
+
#include "virsh-edit.c"
+#undefine EDIT_RELAX
vshPrint(ctl, _("Domain %s XML configuration edited.\n"),
virDomainGetName(dom_edited));
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 41a6d53..2a13a04 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -1,7 +1,7 @@
/*
* virsh-edit.c: Implementation of generic virsh *-edit intelligence
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2015 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
@@ -62,6 +62,7 @@ do {
char *doc_reread = NULL;
const char *msg = NULL;
bool edit_success = false;
+ bool relax_avail = false;
/* Get the XML configuration of the object. */
doc = (EDIT_GET_XML);
@@ -74,6 +75,11 @@ do {
goto edit_cleanup;
reedit:
+
+#ifdef EDIT_RELAX
+ relax_avail = true;
+#endif
+
/* Start the editor. */
if (vshEditFile(ctl, tmp) == -1)
goto edit_cleanup;
@@ -112,7 +118,7 @@ do {
msg = _("Failed.");
if (msg) {
- int c = vshAskReedit(ctl, msg);
+ int c = vshAskReedit(ctl, msg, relax_avail);
switch (c) {
case 'y':
goto reedit;
@@ -126,6 +132,17 @@ do {
goto edit_cleanup;
break;
+#ifdef EDIT_RELAX
+ case 'v':
+ if (relax_avail) {
+ EDIT_RELAX;
+ relax_avail = false;
+ goto redefine;
+ break;
+ }
+ /* fall-through */
+#endif
+
default:
vshError(ctl, "%s", msg);
break;
diff --git a/tools/virsh.c b/tools/virsh.c
index aba34ce..464af3d 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 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
@@ -512,13 +512,14 @@ vshPrintRaw(vshControl *ctl, ...)
* edited file.
*
* Returns 'y' if he wants to
- * 'f' if he forcibly wants to
* 'n' if he doesn't want to
+ * 'v' if he wants to try defining it again with validation turned off
+ * 'f' if he forcibly wants to
* -1 on error
* 0 otherwise
*/
int
-vshAskReedit(vshControl *ctl, const char *msg)
+vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
{
int c = -1;
@@ -532,8 +533,9 @@ vshAskReedit(vshControl *ctl, const char *msg)
while (true) {
/* TRANSLATORS: For now, we aren't using LC_MESSAGES, and the user
- * choices really are limited to just 'y', 'n', 'f' and '?' */
- vshPrint(ctl, "\r%s %s", msg, _("Try again? [y,n,f,?]:"));
+ * choices really are limited to just 'y', 'n', 'v', 'f' and '?' */
+ vshPrint(ctl, _("\r%s Try again? %s: "), msg,
+ relax_avail ? "[y,n,v,f,?]" : "[y,n,f,?]");
c = c_tolower(getchar());
if (c == '?') {
@@ -541,11 +543,21 @@ vshAskReedit(vshControl *ctl, const char *msg)
"",
_("y - yes, start editor again"),
_("n - no, throw away my changes"),
+ NULL);
+
+ if (relax_avail) {
+ vshPrintRaw(ctl,
+ _("v - turn off validation and try to redefine again"),
+ NULL);
+ }
+
+ vshPrintRaw(ctl,
_("f - force, try to redefine again"),
_("? - print this help"),
NULL);
continue;
- } else if (c == 'y' || c == 'n' || c == 'f') {
+ } else if (c == 'y' || c == 'n' || c == 'f' ||
+ (relax_avail && c == 'v')) {
break;
}
}
@@ -557,7 +569,9 @@ vshAskReedit(vshControl *ctl, const char *msg)
}
#else /* WIN32 */
int
-vshAskReedit(vshControl *ctl, const char *msg ATTRIBUTE_UNUSED)
+vshAskReedit(vshControl *ctl,
+ const char *msg ATTRIBUTE_UNUSED,
+ bool relax_avail ATTRIBUTE_UNUSED)
{
vshDebug(ctl, VSH_ERR_WARNING, "%s", _("This function is not "
"supported on WIN32 platform"));
diff --git a/tools/virsh.h b/tools/virsh.h
index 7d5d8a2..df2ea7f 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -1,7 +1,7 @@
/*
* virsh.h: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 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
@@ -359,7 +359,7 @@ char *vshGetTypedParamValue(vshControl *ctl, virTypedParameterPtr item)
char *vshEditWriteToTempFile(vshControl *ctl, const char *doc);
int vshEditFile(vshControl *ctl, const char *filename);
char *vshEditReadBackFile(vshControl *ctl, const char *filename);
-int vshAskReedit(vshControl *ctl, const char *msg);
+int vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail);
int vshStreamSink(virStreamPtr st, const char *bytes, size_t nbytes,
void *opaque);
double vshPrettyCapacity(unsigned long long val, const char **unit);
--
2.3.0
9 years, 9 months
[libvirt] [PATCH] network: allow <pf> together with <interface>/<address> in network status
by Laine Stump
The function that parses the <forward> subelement of a network used to
fail/log an error if the network definition contained both a <pf>
element as well as at least one <interface> or <address> element. That
check was present because the configuration of a network should have
either one <pf>, one or more <interface>, or one or more <address>,
but never combinations of multiple kinds.
This caused a problem when libvirtd was restarted with a network
already active - when a network with a <pf> element is started, the
referenced PF (Physical Function of an SRIOV-capable network card) is
checked for VFs (Virtual Functions), and the <forward> is filled in
with a list of all VFs for that PF either in the form of their PCI
addresses (a list of <address>) or their netdev names (a list of
<interface>); the <pf> element is not removed though. When libvirtd is
restarted, it parses the network status and finds both the original
<pf> from the config, as well as the list of either <address> or
<interface>, fails the parse, and the network is not added to the
active list. This failure is often obscured because the network is
marked as autostart so libvirt immediately restarts it.
It seems odd to me that <interface> and <address> are stored in the
same array rather than keeping two separate arrays, and having
separate arrays would have made the check much simpler. However,
changing to use two separate arrays would have required changes in
more places, potentially creating more conflicts and (more
importantly) more possible regressions in the event of a backport, so
I chose to keep the existing data structure in order to localize the
change.
It appears that this problem has been in the code ever since support
for <pf> was added (0.9.10), but until commit
34cc3b2f106e296df5e64309620c79d16fd76c85 (first in libvirt 1.2.4)
networks with interface pools were not properly marked as active on
restart anyway, so there is no point in backporting this patch any
further than that.
---
src/conf/network_conf.c | 10 +---------
src/network/bridge_driver.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index f947d89..dce3360 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1,7 +1,7 @@
/*
* network_conf.c: network XML handling
*
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -1638,14 +1638,6 @@ virNetworkForwardDefParseXML(const char *networkName,
goto cleanup;
}
- if (((nForwardIfs > 0) + (nForwardAddrs > 0) + (nForwardPfs > 0)) > 1) {
- virReportError(VIR_ERR_XML_ERROR,
- _("<address>, <interface>, and <pf> elements in <forward> "
- "of network %s are mutually exclusive"),
- networkName);
- goto cleanup;
- }
-
forwardDev = virXPathString("string(./@dev)", ctxt);
if (forwardDev && (nForwardAddrs > 0 || nForwardPfs > 0)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2798010..af16c25 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2734,6 +2734,7 @@ networkValidate(virNetworkDefPtr def,
virNetworkIpDefPtr ipdef;
bool ipv4def = false, ipv6def = false;
bool bandwidthAllowed = true;
+ bool usesInterface = false, usesAddress = false;
/* check for duplicate networks */
if (virNetworkObjIsDuplicate(&driver->networks, def, check_active) < 0)
@@ -2798,6 +2799,40 @@ networkValidate(virNetworkDefPtr def,
bandwidthAllowed = false;
}
+ /* we support configs with a single PF defined:
+ * <pf dev='eth0'/>
+ * or with a list of netdev names:
+ * <interface dev='eth9'/>
+ * OR a list of PCI addresses
+ * <address type='pci' domain='0' bus='4' slot='0' function='1'/>
+ * but not any combination of those.
+ *
+ * Since <interface> and <address> are for some strange reason
+ * stored in the same array, we need to cycle through it and check
+ * the type of each.
+ */
+ for (i = 0; i < def->forward.nifs; i++) {
+ switch ((virNetworkForwardHostdevDeviceType)
+ def->forward.ifs[i].type) {
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV:
+ usesInterface = true;
+ break;
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
+ usesAddress = true;
+ break;
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE:
+ case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST:
+ break;
+ }
+ }
+ if ((def->forward.npfs > 0) + usesInterface + usesAddress > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("<address>, <interface>, and <pf> elements of "
+ "<forward> in network %s are mutually exclusive"),
+ def->name);
+ return -1;
+ }
+
/* We only support dhcp on one IPv4 address and
* on one IPv6 address per defined network
*/
--
2.1.0
9 years, 9 months
[libvirt] dmidecode dependency
by Jason Helfman
Hello All,
I was wondering if it may be possible to call sysctl, instead of requiring
dmidecode to be installed for getting the uuid of a system?
According to the user that filed the bug below, dmidecode needs to be
installed to get the uuid, or errors will be printed in logs to get the
uuid.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196733
I was wondering if sysctl can be called to get this information for
FreeBSD? I am not sure if Linux would give similar information, but would
think it might. Beyond this, I am not sure if dmidecode is used for other
aspects beyond uuid where it is required where sysctl doesn't give the
information needed.
$ sudo dmidecode |grep -i uuid
UUID: 42355DE8-C55C-E487-8E16-509A78EB5EE1
$ sysctl kern.hostuuid
kern.hostuuid: 42355de8-c55c-e487-8e16-509a78eb5ee1
Thanks,
Jason
--
Jason Helfman | FreeBSD Committer
jgh(a)FreeBSD.org | http://people.freebsd.org/~jgh | The Power to Serve
9 years, 9 months
[libvirt] [RFC PATCH] Use PAUSED state for domains that are starting up
by Jiri Denemark
When libvirt is starting a domain, it reports the state as SHUTOFF until
it's RUNNING. This is not ideal because domain startup may take a long
time (usually because of some configuration issues, firewalls blocking
access to network disks, etc.) and domain lists provided by libvirt look
awkward. One can see weird shutoff domains with IDs in a list of active
domains or even shutoff transient domains. In any case, it looks more
like a bug in libvirt than a normal state a domain goes through.
I'm not quite sure what the best way to fix this is. In this patch, I
tried to use PAUSED state with STARTING_UP reason. Alternatively, we
could keep using SHUTOFF state and just set STARTING_UP reason instead
of UNKNOWN but it just feels wrong and wouldn't really solve the
confusion when looking at virsh list.
I made the change to qemu driver only in this RFC patch, I will update
all drivers once we agree on the best approach.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
include/libvirt/libvirt-domain.h | 1 +
src/conf/domain_conf.c | 3 ++-
src/qemu/qemu_process.c | 22 ++++++++++++++--------
tools/virsh-domain-monitor.c | 3 ++-
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4dbd7f5..90150f6 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -116,6 +116,7 @@ typedef enum {
VIR_DOMAIN_PAUSED_SHUTTING_DOWN = 8, /* paused during shutdown process */
VIR_DOMAIN_PAUSED_SNAPSHOT = 9, /* paused while creating a snapshot */
VIR_DOMAIN_PAUSED_CRASHED = 10, /* paused due to a guest crash */
+ VIR_DOMAIN_PAUSED_STARTING_UP = 11, /* the domain is being started */
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_PAUSED_LAST
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b3d63f8..2b7c5bf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -661,7 +661,8 @@ VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST,
"from snapshot",
"shutdown",
"snapshot",
- "panicked")
+ "panicked",
+ "starting up")
VIR_ENUM_IMPL(virDomainShutdownReason, VIR_DOMAIN_SHUTDOWN_LAST,
"unknown",
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1d4e957..d317b19 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3412,6 +3412,7 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
virDomainState state;
virDomainPausedReason reason;
virDomainState newState = VIR_DOMAIN_NOSTATE;
+ int oldReason;
int newReason;
bool running;
char *msg = NULL;
@@ -3425,9 +3426,16 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
if (ret < 0)
return -1;
- state = virDomainObjGetState(vm, NULL);
+ state = virDomainObjGetState(vm, &oldReason);
- if (state == VIR_DOMAIN_PAUSED && running) {
+ if (running &&
+ (state == VIR_DOMAIN_SHUTOFF ||
+ (state == VIR_DOMAIN_PAUSED &&
+ oldReason == VIR_DOMAIN_PAUSED_STARTING_UP))) {
+ newState = VIR_DOMAIN_RUNNING;
+ newReason = VIR_DOMAIN_RUNNING_BOOTED;
+ ignore_value(VIR_STRDUP_QUIET(msg, "finished booting"));
+ } else if (state == VIR_DOMAIN_PAUSED && running) {
newState = VIR_DOMAIN_RUNNING;
newReason = VIR_DOMAIN_RUNNING_UNPAUSED;
ignore_value(VIR_STRDUP_QUIET(msg, "was unpaused"));
@@ -3446,10 +3454,6 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
ignore_value(virAsprintf(&msg, "was paused (%s)",
virDomainPausedReasonTypeToString(reason)));
}
- } else if (state == VIR_DOMAIN_SHUTOFF && running) {
- newState = VIR_DOMAIN_RUNNING;
- newReason = VIR_DOMAIN_RUNNING_BOOTED;
- ignore_value(VIR_STRDUP_QUIET(msg, "finished booting"));
}
if (newState != VIR_DOMAIN_NOSTATE) {
@@ -3817,7 +3821,9 @@ qemuProcessReconnect(void *opaque)
goto error;
state = virDomainObjGetState(obj, &reason);
- if (state == VIR_DOMAIN_SHUTOFF) {
+ if (state == VIR_DOMAIN_SHUTOFF ||
+ (state == VIR_DOMAIN_PAUSED &&
+ reason == VIR_DOMAIN_PAUSED_STARTING_UP)) {
VIR_DEBUG("Domain '%s' wasn't fully started yet, killing it",
obj->def->name);
goto error;
@@ -4435,7 +4441,7 @@ int qemuProcessStart(virConnectPtr conn,
vm->def->id = qemuDriverAllocateID(driver);
qemuDomainSetFakeReboot(driver, vm, false);
- virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_UNKNOWN);
+ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_STARTING_UP);
if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
driver->inhibitCallback(true, driver->inhibitOpaque);
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 925eb1b..da23ace 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -184,7 +184,8 @@ VIR_ENUM_IMPL(vshDomainPausedReason,
N_("from snapshot"),
N_("shutting down"),
N_("creating snapshot"),
- N_("crashed"))
+ N_("crashed"),
+ N_("starting up"))
VIR_ENUM_DECL(vshDomainShutdownReason)
VIR_ENUM_IMPL(vshDomainShutdownReason,
--
2.3.0
9 years, 9 months
[libvirt] [PATCH] virsh-edit: Make force editing usable
by Martin Kletzander
When editing a domain with 'virsh edit' and failing validation, the
usual message pops up:
Failed. Try again? [y,n,f,?]:
The option 'f' (force) is pretty unusable. It tries to step into the
same puddle again and again when it can at least try to force the
definition.
This patch adds support for relaxing definition in virsh-edit and makes
'virsh edit <domain>' more usable, mainly for testing.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
tools/virsh-domain.c | 5 +++++
tools/virsh-edit.c | 5 ++++-
tools/virsh.c | 4 ++--
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2506b89..3dd676c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11265,6 +11265,11 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
} while (0)
#define EDIT_DEFINE \
(dom_edited = vshDomainDefine(ctl->conn, doc_edited, define_flags))
+#define EDIT_RELAX \
+ do { \
+ define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE; \
+ } while (0);
+
#include "virsh-edit.c"
vshPrint(ctl, _("Domain %s XML configuration edited.\n"),
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 41a6d53..3186998 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -1,7 +1,7 @@
/*
* virsh-edit.c: Implementation of generic virsh *-edit intelligence
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2015 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
@@ -119,6 +119,9 @@ do {
break;
case 'f':
+#ifdef EDIT_RELAX
+ EDIT_RELAX;
+#endif
goto redefine;
break;
diff --git a/tools/virsh.c b/tools/virsh.c
index aba34ce..5b154e1 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 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
@@ -541,7 +541,7 @@ vshAskReedit(vshControl *ctl, const char *msg)
"",
_("y - yes, start editor again"),
_("n - no, throw away my changes"),
- _("f - force, try to redefine again"),
+ _("f - force, try to redefine again (without validation)"),
_("? - print this help"),
NULL);
continue;
--
2.3.0
9 years, 9 months
[libvirt] [PATCH 1/3] parallels: code aligment
by Mikhail Feoktistov
---
src/parallels/parallels_sdk.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d0d2ce2..3bb2ce8 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2804,23 +2804,23 @@ prlsdkDoApplyConfig(PRL_HANDLE sdkdom,
goto error;
for (i = 0; i < def->nserials; i++) {
- if (prlsdkAddSerial(sdkdom, def->serials[i]) < 0)
- goto error;
+ if (prlsdkAddSerial(sdkdom, def->serials[i]) < 0)
+ goto error;
}
for (i = 0; i < def->nnets; i++) {
- if (prlsdkAddNet(sdkdom, def->nets[i]) < 0)
- goto error;
+ if (prlsdkAddNet(sdkdom, def->nets[i]) < 0)
+ goto error;
}
for (i = 0; i < def->ndisks; i++) {
- if (prlsdkAddDisk(sdkdom, def->disks[i]) < 0)
- goto error;
+ if (prlsdkAddDisk(sdkdom, def->disks[i]) < 0)
+ goto error;
}
for (i = 0; i < def->nfss; i++) {
- if (prlsdkAddFS(sdkdom, def->fss[i]) < 0)
- goto error;
+ if (prlsdkAddFS(sdkdom, def->fss[i]) < 0)
+ goto error;
}
return 0;
--
1.7.1
9 years, 9 months
[libvirt] [PATCH v2] Search for schemas and cpu_map.xml in source tree
by Jiri Denemark
Not all files we want to find using virFileFindResource{,Full} are
generated when libvirt is built, some of them (such as RNG schemas) are
distributed with sources. The current API was not able to find source
files if libvirt was built in VPATH.
Both RNG schemas and cpu_map.xml are distributed in source tarball.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/Makefile.am | 2 ++
src/conf/domain_conf.c | 2 +-
src/cpu/cpu_map.c | 2 +-
src/driver.c | 2 +-
src/fdstream.c | 2 +-
src/locking/lock_driver_lockd.c | 2 +-
src/locking/lock_manager.c | 2 +-
src/lxc/lxc_conf.c | 2 +-
src/network/bridge_driver.c | 2 +-
src/remote/remote_driver.c | 2 +-
src/storage/storage_backend_disk.c | 4 ++--
src/util/virfile.c | 30 ++++++++++++++++--------------
12 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index b41c6d4..a938d7e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,7 @@
abs_builddir = $(shell pwd)
abs_topbuilddir = $(shell cd .. && pwd)
abs_srcdir = $(shell cd $(srcdir) && pwd)
+abs_topsrcdir = $(shell cd $(srcdir)/.. && pwd)
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
@@ -32,6 +33,7 @@ INCLUDES = -I../gnulib/lib \
-I$(srcdir)/util \
-DIN_LIBVIRT \
-Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \
+ -Dabs_topsrcdir="\"$(abs_topsrcdir)\"" \
$(GETTEXT_CPPFLAGS)
AM_CFLAGS = $(LIBXML_CFLAGS) \
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b13cae8..2e35293 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12887,7 +12887,7 @@ virDomainDefParseXML(xmlDocPtr xml,
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
char *schema = virFileFindResource("domain.rng",
- "docs/schemas",
+ abs_topsrcdir "/docs/schemas",
PKGDATADIR "/schemas");
if (!schema)
return NULL;
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index b77f688..6130f8a 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -87,7 +87,7 @@ int cpuMapLoad(const char *arch,
char *mapfile;
if (!(mapfile = virFileFindResource("cpu_map.xml",
- "src/cpu",
+ abs_topsrcdir "/src/cpu",
PKGDATADIR)))
return -1;
diff --git a/src/driver.c b/src/driver.c
index 1be32ef..db03438 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -56,7 +56,7 @@ virDriverLoadModule(const char *name)
if (!(modfile = virFileFindResourceFull(name,
"libvirt_driver_",
".so",
- "src/.libs",
+ abs_topbuilddir "/src/.libs",
LIBDIR "/libvirt/connection-driver",
"LIBVIRT_DRIVER_DIR")))
return NULL;
diff --git a/src/fdstream.c b/src/fdstream.c
index 18bd359..5d80fc2 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
}
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 2af3f22..8d184fe 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -253,7 +253,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
if (!privileged &&
!(daemonPath = virFileFindResourceFull("virtlockd",
NULL, NULL,
- "src",
+ abs_topbuilddir "/src",
SBINDIR,
"VIRTLOCKD_PATH")))
goto error;
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index ec90d04..f277f22 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -142,7 +142,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
if (!(modfile = virFileFindResourceFull(name,
NULL,
".so",
- "src/.libs",
+ abs_topbuilddir "/src/.libs",
LIBDIR "/libvirt/lock-driver",
"LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
goto cleanup;
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index b6d1797..d1a3be5 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -94,7 +94,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
}
if (!(lxc_path = virFileFindResource("libvirt_lxc",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2798010..404e90b 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1289,7 +1289,7 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
/* This helper is used to create custom leases file for libvirt */
if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d4fd658..76c1d0c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -887,7 +887,7 @@ doRemoteOpen(virConnectPtr conn,
if ((flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) &&
!(daemonPath = virFileFindResourceFull("libvirtd",
NULL, NULL,
- "daemon",
+ abs_topbuilddir "/daemon",
SBINDIR,
"LIBVIRTD_PATH")))
goto failed;
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 9f4d76a..39082cc 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -301,7 +301,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
return -1;
@@ -346,7 +346,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
return -1;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 1b004d6..91dd0b8 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -248,7 +248,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
}
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
@@ -1618,7 +1618,8 @@ static bool useDirOverride;
* @filename: libvirt distributed filename without any path
* @prefix: optional string to prepend to filename
* @suffix: optional string to append to filename
- * @builddir: location of the binary in the source tree build tree
+ * @builddir: location of the filename in the build tree including
+ * abs_topsrcdir or abs_topbuilddir prefix
* @installdir: location of the installed binary
* @envname: environment variable used to override all dirs
*
@@ -1628,7 +1629,7 @@ static bool useDirOverride;
* path in the installed location.
*
* If @envname is non-NULL it will override all other
- * directory lookup
+ * directory lookup.
*
* Only use this with @filename files that are part of
* the libvirt tree, not 3rd party binaries/files.
@@ -1645,22 +1646,22 @@ virFileFindResourceFull(const char *filename,
{
char *ret = NULL;
const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL;
+ const char *path;
if (!prefix)
prefix = "";
if (!suffix)
suffix = "";
- if (envval) {
- if (virAsprintf(&ret, "%s/%s%s%s", envval, prefix, filename, suffix) < 0)
- return NULL;
- } else if (useDirOverride) {
- if (virAsprintf(&ret, "%s/%s/%s%s%s", abs_topbuilddir, builddir, prefix, filename, suffix) < 0)
- return NULL;
- } else {
- if (virAsprintf(&ret, "%s/%s%s%s", installdir, prefix, filename, suffix) < 0)
- return NULL;
- }
+ if (envval)
+ path = envval;
+ else if (useDirOverride)
+ path = builddir;
+ else
+ path = installdir;
+
+ if (virAsprintf(&ret, "%s/%s%s%s", path, prefix, filename, suffix) < 0)
+ return NULL;
VIR_DEBUG("Resolved '%s' to '%s'", filename, ret);
return ret;
@@ -1671,7 +1672,8 @@ virFileFindResource(const char *filename,
const char *builddir,
const char *installdir)
{
- return virFileFindResourceFull(filename, NULL, NULL, builddir, installdir, NULL);
+ return virFileFindResourceFull(filename, NULL, NULL, builddir,
+ installdir, NULL);
}
--
2.3.0
9 years, 9 months
[libvirt] [PATCH v3 0/6] Propagate storage errors on migration
by Michal Privoznik
diff to v3:
- Took a step further and introduced a condition to wait on
Michal Privoznik (6):
qemuProcessHandleBlockJob: Set disk->mirrorState more often
qemuProcessHandleBlockJob: Take status into account
qemuMigrationDriveMirror: Listen to events
qemuDomainObjPrivate: Introduce blockJob condition
qemuMigrationDriveMirror: utilize blockJob condition
qemuDomainBlockJobImpl: utilize blockJob condition
src/qemu/qemu_domain.c | 4 +++-
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 15 ++++++--------
src/qemu/qemu_migration.c | 50 ++++++++++++++++++++---------------------------
src/qemu/qemu_process.c | 40 +++++++++++++++++++++++--------------
5 files changed, 57 insertions(+), 54 deletions(-)
--
2.0.5
9 years, 9 months
[libvirt] [PATCH 0/2] qemu: Improve virDomainGetControlInfo
by Peter Krempa
Peter Krempa (2):
qemu: Properly report error state in qemuDomainGetControlInfo()
qemu: Allow inactive domains in qemuDomainGetControlInfo()
include/libvirt/libvirt-domain.h | 27 +++++++++++++++++++++++++--
src/qemu/qemu_driver.c | 21 +++++++++++++--------
tools/virsh-domain-monitor.c | 19 +++++++++++++++++++
3 files changed, 57 insertions(+), 10 deletions(-)
--
2.2.2
9 years, 9 months
[libvirt] starting LXC container with user namespace with root FS in image (with loop device)
by Dmitry Guryanov
Hello,
I have a container with root fs:
<filesystem type='file' accessmode='passthrough'>
<driver type='loop' format='raw'/>
<source file='/opt/stack/data/nova/instances/x/disk'/>
<target dir='/'/>
</filesystem>
And it seems libvirt tries to mount this FS from a user namespace, which
is not possible:
[root@localhost ~]# virsh -c lxc:/// start instance-0000000aXX
error: Failed to start domain instance-0000000aXX
error: internal error: guest failed to start: Failed to mount device
/dev/loop3 to /var/run/libvirt/lxc/instance-0000000aXX.root: Operation
not permitted
Do you have any ideas, how it's supposed to work?
Here is domain config:
<domain type='lxc'>
<name>instance-0000000aXX</name>
<uuid>c68df696-1499-4cb3-b1fa-e2a370c11382</uuid>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<cputune>
<shares>1024</shares>
</cputune>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
<cmdline>console=tty0 console=ttyS0</cmdline>
</os>
<idmap>
<uid start='0' target='10000' count='1000'/>
<gid start='0' target='10000' count='1000'/>
</idmap>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='file' accessmode='passthrough'>
<driver type='loop' format='raw'/>
<source file='/opt/stack/data/nova/instances/x/disk'/>
<target dir='/'/>
</filesystem>
<console type='pty'>
<target type='lxc' port='0'/>
</console>
</devices>
</domain>
--
Dmitry Guryanov
9 years, 9 months