[libvirt] [PATCH] New virsh feature: domif-setlink --domain --interface --state completer
by Simon Kobyda
After you go through command mentioned above, completer finds
what state the device is currently in, and suggests an opposite state.
---
tools/virsh-completer.c | 73 ++++++++++++++++++++++++++++++++++++++++-
tools/virsh-completer.h | 4 +++
tools/virsh-domain.c | 1 +
3 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 2327e08340..e32fd82211 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -32,6 +32,7 @@
#include "internal.h"
#include "virutil.h"
#include "viralloc.h"
+#include "virmacaddr.h"
#include "virstring.h"
#include "virxml.h"
@@ -750,7 +751,6 @@ virshDomainEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
return NULL;
}
-
char **
virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd ATTRIBUTE_UNUSED,
@@ -776,6 +776,77 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
return NULL;
}
+char **
+virshDomainInterfaceStateCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virshControlPtr priv = ctl->privData;
+ const char *iface = NULL;
+ char **ret = NULL;
+ xmlDocPtr xml = NULL;
+ virMacAddr macaddr;
+ char *state = NULL;
+ char *xpath = NULL;
+ char macstr[18] = "";
+ xmlXPathContextPtr ctxt = NULL;
+ xmlNodePtr *interfaces = NULL;
+ int ninterfaces;
+
+ virCheckFlags(0, NULL);
+
+ if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
+ return NULL;
+
+ if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0)
+ goto cleanup;
+
+ if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0)
+ goto cleanup;
+
+ /* normalize the mac addr */
+ if (virMacAddrParse(iface, &macaddr) == 0)
+ virMacAddrFormat(&macaddr, macstr);
+
+ if (virAsprintf(&xpath, "/domain/devices/interface[(mac/@address = '%s') or "
+ " (target/@dev = '%s')]",
+ macstr, iface) < 0)
+ goto cleanup;
+
+ if ((ninterfaces = virXPathNodeSet(xpath, ctxt, &interfaces)) < 0)
+ goto cleanup;
+
+ if (ninterfaces != 1)
+ goto cleanup;
+
+ ctxt->node = interfaces[0];
+
+ if (VIR_ALLOC_N(ret, 2) < 0)
+ goto error;
+
+ if ((state = virXPathString("string(./link/@state)", ctxt)) &&
+ STREQ(state, "down")) {
+ if (VIR_STRDUP(ret[0], "up") < 0)
+ goto error;
+ } else {
+ if (VIR_STRDUP(ret[0], "down") < 0)
+ goto error;
+ }
+
+ cleanup:
+ VIR_FREE(state);
+ VIR_FREE(interfaces);
+ VIR_FREE(xpath);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ return ret;
+
+ error:
+ virStringListFree(ret);
+ ret = NULL;
+ goto cleanup;
+}
+
char **
virshNodedevEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h
index 1c14bb2a54..b4fd2a86c6 100644
--- a/tools/virsh-completer.h
+++ b/tools/virsh-completer.h
@@ -94,6 +94,10 @@ char ** virshPoolEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
+char ** virshDomainInterfaceStateCompleter(vshControl *ctl,
+ const vshCmd *cmd,
+ unsigned int flags);
+
char ** virshNodedevEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3959b5475b..8adec1d9b1 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3064,6 +3064,7 @@ static const vshCmdOptDef opts_domif_setlink[] = {
{.name = "state",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+ .completer = virshDomainInterfaceStateCompleter,
.help = N_("new state of the device")
},
{.name = "persistent",
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] util: Drop virArgvToString()
by Andrea Bolognani
The last use has been removed in 026ae4933c6a.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/libvirt_private.syms | 1 -
src/util/virstring.c | 27 ---------------------------
src/util/virstring.h | 2 --
3 files changed, 30 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e688981c3e..1caecb96b6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2876,7 +2876,6 @@ virStorageFileBackendRegister;
# util/virstring.h
-virArgvToString;
virAsprintfInternal;
virSkipSpaces;
virSkipSpacesAndBackslash;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 15f367af7c..31e71d7535 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -917,33 +917,6 @@ virStringIsEmpty(const char *str)
return str[0] == '\0';
}
-char *
-virArgvToString(const char *const *argv)
-{
- int len;
- size_t i;
- char *ret, *p;
-
- for (len = 1, i = 0; argv[i]; i++)
- len += strlen(argv[i]) + 1;
-
- if (VIR_ALLOC_N(ret, len) < 0)
- return NULL;
- p = ret;
-
- for (i = 0; argv[i]; i++) {
- if (i != 0)
- *(p++) = ' ';
-
- strcpy(p, argv[i]);
- p += strlen(argv[i]);
- }
-
- *p = '\0';
-
- return ret;
-}
-
/**
* virStrdup:
* @dest: where to store duplicated string
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 726e02b98c..14948fdf1c 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -65,8 +65,6 @@ char *virStringListGetFirstWithPrefix(char **strings,
const char *prefix)
ATTRIBUTE_NONNULL(2);
-char *virArgvToString(const char *const *argv);
-
int virStrToLong_i(char const *s,
char **end_ptr,
int base,
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] util: Remove ATTRIBUTE_NONNULL from virNetDevTapInterfaceStats
by John Ferlan
Commit id 318d54e520 altered the code to check for a NULL
first parameter, but neglected to alter the prototype.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Pushed under the trivial rule and as a Coverity build breaker.
src/util/virnetdevtap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h
index 727368fe95..37f9367ff4 100644
--- a/src/util/virnetdevtap.h
+++ b/src/util/virnetdevtap.h
@@ -94,6 +94,6 @@ int virNetDevTapCreateInBridgePort(const char *brname,
int virNetDevTapInterfaceStats(const char *ifname,
virDomainInterfaceStatsPtr stats,
bool swapped)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_RETURN_CHECK;
#endif /* __VIR_NETDEV_TAP_H__ */
--
2.17.1
6 years, 4 months
Re: [libvirt] [Qemu-devel] [PULL 25/26] block: Remove deprecated -drive option serial
by Christian Borntraeger
On 06/15/2018 04:21 PM, Kevin Wolf wrote:
> The -drive option serial was deprecated in QEMU 2.10. It's time to
> remove it.
>
> Tests need to be updated to set the serial number with -global instead
> of using the -drive option.
libvirt 4.5 still creates those (at least on s390x)
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none' io='native' iothread='1'/>
<source file='/var/lib/libvirt/qemu/image.zhyp137'/>
<target dev='hda' bus='virtio'/>
<serial>skel</serial>
<boot order='1'/>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
</disk>
->
[...]
-drive file=/var/lib/libvirt/qemu/image.zhyp137,format=qcow2,if=none,id=drive-virtio-disk0,serial=skel,cache=none,aio=native -device virtio-blk-ccw,iothread=iothread1,scsi=off,devno=fe.0.0000,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,write-cache=on
[...]
2018-06-22T11:25:20.946024Z qemu-system-s390x: -drive file=/var/lib/libvirt/qemu/image.zhyp137,format=qcow2,if=none,id=drive-virtio-disk0,serial=skel,cache=none,aio=native: Block format 'qcow2' does not support the option 'serial'
2018-06-22 11:25:21.098+0000: shutting down, reason=failed
So it seems that this breaks s390x.
6 years, 4 months
[libvirt] [PATCH v2 0/9] Resolve libvirtd hang on termination with connected long running client
by John Ferlan
v1: https://www.redhat.com/archives/libvir-list/2018-January/msg00624.html
Cannot recall differences from v1.
Since so much changed since v1, figured it'd be easier to just repost
to continue the discussion.
John Ferlan (9):
libvirtd: Alter refcnt processing for domain server objects
libvirtd: Alter refcnt processing for server program objects
util: Introduce virThreadPoolQuitRequested
rpc: Introduce virNetServerQuitRequested
rpc: Introduce virNetServerWorkerCount
daemon: Add quit_timeout period
rpc: Alter virNetDaemonQuit processing
docs: Add news article for libvirtd issue
APPLY ONLY FOR TESTING PURPOSES
docs/news.xml | 12 +++++
src/libvirt_private.syms | 1 +
src/libvirt_remote.syms | 3 ++
src/qemu/qemu_driver.c | 5 ++
src/remote/libvirtd.aug | 1 +
src/remote/libvirtd.conf | 8 +++
src/remote/remote_daemon.c | 40 ++++++++++-----
src/remote/remote_daemon_config.c | 5 ++
src/remote/remote_daemon_config.h | 2 +
src/remote/test_libvirtd.aug.in | 1 +
src/rpc/virnetdaemon.c | 82 ++++++++++++++++++++++++++++++-
src/rpc/virnetdaemon.h | 4 ++
src/rpc/virnetserver.c | 50 +++++++++++++++++++
src/rpc/virnetserver.h | 4 ++
src/util/virthreadpool.c | 51 ++++++++++++++++---
src/util/virthreadpool.h | 2 +
16 files changed, 250 insertions(+), 21 deletions(-)
--
2.17.1
6 years, 4 months
[libvirt] [PATCH 0/9] extend virsh domstate to show additional information
by Bjoern Walk
This patch series introduces the ability to save additional information
for the domain state and exposes this information in virsh domstate.
For example in the case of QEMU guest panic events, we can provide additional
information like the crash reason or register state of the domain. This
information usually gets logged in the domain log but for debugging it is
useful to have it accessible from the client. Therefore, let's introduce a new
public API function, virDomainGetStateParams, an extensible version of
virDomainGetState, which returns the complete state of the domain, including
newly introduced additional information.
Let's also extend virsh domstate and introduce a new parameter --info to show
the domain state, reason and additional information when available.
virsh # domstate --info guest-1
crashed (panicked: disabled-wait core='1' psw-mask='0x000000000010f146' \
psw-addr='0x0002000180000000')
Bjoern Walk (9):
conf: add info to virDomainStateReason
conf: set/retrieve state information
lib: introduce virDomainGetStateParams function
remote: implement remoteDomainGetStateParams
qemu: implement qemuDomainGetStateParams
qemu: set state information for guest panic event
virsh: domstate: report detailed state if available
news: add entry for virDomainGetStateParams
qemu: fix order of S390 panic event information
docs/news.xml | 11 ++++++
include/libvirt/libvirt-domain.h | 24 ++++++++++++
src/conf/domain_conf.c | 16 +++++++-
src/conf/domain_conf.h | 7 ++++
src/driver-hypervisor.h | 7 ++++
src/libvirt-domain.c | 56 ++++++++++++++++++++++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 +++
src/qemu/qemu_driver.c | 61 ++++++++++++++++++++++++++++-
src/qemu/qemu_monitor.c | 39 ++++++++++++++++--
src/qemu/qemu_monitor.h | 1 +
src/remote/remote_daemon_dispatch.c | 1 -
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 20 +++++++++-
src/remote_protocol-structs | 11 ++++++
tools/virsh-domain-monitor.c | 31 ++++++++++++---
tools/virsh.pod | 5 ++-
17 files changed, 281 insertions(+), 16 deletions(-)
--
2.17.0
6 years, 4 months
[libvirt] [PATCH] qemu: hotplug: report error when changing rom enabled attr for net iface
by Katerina Koukiou
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1599513
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3dfa51b0a0..bb50d19c85 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3222,6 +3222,11 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
_("cannot modify network device boot index setting"));
goto cleanup;
}
+ if (olddev->info.romenabled != newdev->info.romenabled) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("cannot modify network device rom enabled setting"));
+ goto cleanup;
+ }
/* (end of device info checks) */
if (STRNEQ_NULLABLE(olddev->filter, newdev->filter) ||
--
2.15.0
6 years, 4 months
[libvirt] [PATCH v2] qemu: fix broken autostart symlink after renaming domain.
by Julio Faracco
If a domain is configured to start on boot, it has a symlink to the
domain definition inside the autostart directory. If you rename this
domain, the definition is renamed too. The symlink need to be pointed to
this renamed file. This commit recreates the symlink after renaming the
XML file.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1594985
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5de9aaefbb..a4df482c9e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20914,6 +20914,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
char *old_dom_name = NULL;
char *new_dom_cfg_file = NULL;
char *old_dom_cfg_file = NULL;
+ char *new_dom_autostart_link = NULL;
+ char *old_dom_autostart_link = NULL;
virCheckFlags(0, ret);
@@ -20934,6 +20936,30 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
vm->def->name)))
goto cleanup;
+ if (vm->autostart) {
+ if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
+ new_dom_name)) ||
+ !(old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
+ vm->def->name)))
+ goto cleanup;
+
+ if (unlink(old_dom_autostart_link) < 0 &&
+ errno != ENOENT &&
+ errno != ENOTDIR) {
+ virReportSystemError(errno,
+ _("Failed to delete symlink '%s'"),
+ old_dom_autostart_link);
+ goto cleanup;
+ }
+
+ if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) {
+ virReportSystemError(errno,
+ _("Failed to create symlink '%s to '%s'"),
+ new_dom_autostart_link, new_dom_cfg_file);
+ goto cleanup;
+ }
+ }
+
event_old = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_UNDEFINED,
VIR_DOMAIN_EVENT_UNDEFINED_RENAMED);
@@ -20960,6 +20986,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
ret = 0;
cleanup:
+ VIR_FREE(old_dom_autostart_link);
+ VIR_FREE(new_dom_autostart_link);
VIR_FREE(old_dom_cfg_file);
VIR_FREE(new_dom_cfg_file);
VIR_FREE(old_dom_name);
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] qemu: fix broken autostart symlink after renaming domain.
by Julio Faracco
If a domain is configured to start on boot, it has a symlink to the
domain definition inside the autostart directory. If you rename this
domain, the definition is renamed too. The symlink need to be pointed to
this renamed file. This commit recreates the symlink after renaming the
XML file.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1594985
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5de9aaefbb..15abb861ec 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20914,6 +20914,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
char *old_dom_name = NULL;
char *new_dom_cfg_file = NULL;
char *old_dom_cfg_file = NULL;
+ char *new_dom_autostart_link = NULL;
+ char *old_dom_autostart_link = NULL;
virCheckFlags(0, ret);
@@ -20934,6 +20936,30 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
vm->def->name)))
goto cleanup;
+ if (vm->autostart) {
+ if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
+ new_dom_name)) ||
+ !(old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
+ vm->def->name)))
+ goto cleanup;
+
+ if (unlink(old_dom_autostart_link) < 0 &&
+ errno != ENOENT &&
+ errno != ENOTDIR) {
+ virReportSystemError(errno,
+ _("Failed to delete symlink '%s'"),
+ old_dom_autostart_link);
+ goto cleanup;
+ }
+
+ if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) {
+ virReportSystemError(errno,
+ _("Failed to create symlink '%s to '%s'"),
+ new_dom_autostart_link, new_dom_cfg_file);
+ goto cleanup;
+ }
+ }
+
event_old = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_UNDEFINED,
VIR_DOMAIN_EVENT_UNDEFINED_RENAMED);
@@ -20960,6 +20986,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
ret = 0;
cleanup:
+ VIR_FREE(old_dom_autostart_link);
+ VIR_FREE(new_dom_autostart_link);
VIR_FREE(old_dom_cfg_file);
VIR_FREE(new_dom_cfg_file);
VIR_FREE(old_dom_name);
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] virmodule: Fix virModuleLoad stub
by Michal Privoznik
When building without dlfcn.h we are providing a virModuleLoad()
stub which is supposed to report an error. However, the format
string in virReportSystemError() call there requires two strings
but we are passing just one.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under build breaker and trivial rules.
src/util/virmodule.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virmodule.c b/src/util/virmodule.c
index b19a787e4f..533cfefc77 100644
--- a/src/util/virmodule.c
+++ b/src/util/virmodule.c
@@ -142,14 +142,14 @@ virModuleLoad(const char *path,
#else /* ! HAVE_DLFCN_H */
int
-virModuleLoad(const char *path ATTRIBUTE_UNUSED,
+virModuleLoad(const char *path,
const char *regfunc ATTRIBUTE_UNUSED,
bool required)
{
VIR_DEBUG("dlopen not available on this platform");
if (required) {
virReportSystemError(ENOSYS,
- _("Failed to find module '%s': %s"), path);
+ _("Failed to find module '%s'"), path);
return -1;
} else {
/* Since we have no dlopen(), but definition we have no
--
2.16.4
6 years, 4 months