[libvirt] [PATCH 0/5] Support forward mode='hostdev' and interface pools
by Shradha Shah
This patch series supports the forward mode='hostdev'. The functionality
of this mode is the same as interface type='hostdev' but with the added
benefit of using interface pools.
The patch series also contains a patch to support use of interface names
and PCI device addresses interchangeably in a network xml, and return
the appropriate one in actualDevice when networkAllocateActualDevice is
called. This functionality is not supported for any other forward mode
except hostdev.
Currently this patch series also does not support USB hostdev
passthrough.
At the top level managed attribute can be specified for a pf dev or an
interface dev (with identical results as when it's specified for a
hostdev
Shradha Shah (5):
Code to return interface name or pci_addr of the VF in actualDevice
Moved the code to create implicit interface pool from PF to a new
function
Introduce forward mode='hostdev' for network XML in order to use the
functionality of interface pools.
Forward Mode Hostdev Implementation
Supporting managed option for forward devs when using HOSTDEV mode
docs/schemas/network.rng | 1 +
src/conf/network_conf.c | 119 +++++++++++++++-
src/conf/network_conf.h | 13 ++-
src/libvirt_private.syms | 3 +
src/network/bridge_driver.c | 325 +++++++++++++++++++++++++++++++++++--------
src/qemu/qemu_command.c | 14 ++
src/util/pci.c | 7 +-
src/util/pci.h | 3 +
src/util/virnetdev.c | 134 +++++++++++++++++-
src/util/virnetdev.h | 19 +++
10 files changed, 568 insertions(+), 70 deletions(-)
--
1.7.4.4
12 years, 6 months
[libvirt] [PATCHv2 0/3] openvz: allow for runtime quota updates
by Guido Günther
Hi,
attached patches allow to change disk quota at runtime. This can later be
extended to update network configuration as well.
The patch revealed a problem of the openvz driver in genral: the
openvzLoadDomains only reads the on disk configuration but doesn't check if
running domains have (non persistent) diverging values due to openvz calls
without the "--save" option but that's part of another patch.
Changes since last time:
* add virDomainFSIndexByName to libvirt_private.syms
* check for unallowed updates in openvzUpdateDevice
Cheers,
-- Guido
Guido Günther (3):
Introduce virDomainFSIndexByName
openvz: add persist parameter to openvzSetDiskQuota
openvz: wire up domainUpdateDeviceFlags
src/conf/domain_conf.c | 16 ++++++
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
src/openvz/openvz_driver.c | 116 ++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 130 insertions(+), 4 deletions(-)
--
1.7.10.4
12 years, 6 months
[libvirt] [sandbox][PATCH]builder-machine: fix incorrect memory allocation
by Radu Caragea
Features should be allocated with 2 elements, one to be "acpi" and one to be a NULL pointer indicating string array termination. (Caught with valgrind)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index 7087459..3f7c5d7 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -391,7 +387,7 @@ static gboolean gvir_sandbox_builder_machine_construct_features(GVirSandboxBuild
construct_features(builder, config, configdir, cleaner, domain, error))
return FALSE;
- features = g_new0(gchar *, 1);
+ features = g_new0(gchar *, 2);
features[0] = g_strdup("acpi");
gvir_config_domain_set_features(domain, features);
g_strfreev(features);
12 years, 6 months
[libvirt] [PATCH 0/2] python bindings cleanups for snapshots
by Eric Blake
I noticed these while working on my new list all snapshots code,
but these are fairly independent and can be applied in any order.
Eric Blake (2):
python: use simpler methods
python: fix snapshot listing bugs
python/libvirt-override.c | 70 ++++++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 27 deletions(-)
--
1.7.10.2
12 years, 6 months
[libvirt] [libvirt-sandbox][PATCH] module lookup and rundir fix
by Radu C.
Hello,
I've been trying to get libvirt-sandbox working on my Gentoo box but I ran into some difficulties. The version I'm using is the latest git one.
The first problem was the following when running virt-sandbox:
"Unable to start sandbox: Error opening file '/tmp/libvirt-sandbox-9ivpRN/9pnet.ko': File exists"
I pinpointed the problem to the following diff in commit [05fb94d2c42abe9cfd86c3663d704c268f325503]:
- gchar *moddirpath = g_strdup_printf("/lib/modules/%s/kernel",
+ gchar *moddirpath = g_strdup_printf("/lib/modules/%s",
The problem is that symlinks are made to the build directory and it finds a module multiple times.
I inserted a printf in the lookup loop so here's what I mean:
dmns libvirt-sandbox # virt-sandbox -c qemu:///system -n test1323 -v
-d /usr/bin/yes
found: /lib/modules/3.4.0-gentoo/kernel/fs/fscache/fscache.ko
found: /lib/modules/3.4.0-gentoo/source/fs/fscache/fscache.ko
found: /lib/modules/3.4.0-gentoo/build/fs/fscache/fscache.ko
found: /lib/modules/3.4.0-gentoo/kernel/net/9p/9pnet.ko
found: /lib/modules/3.4.0-gentoo/source/net/9p/9pnet.ko
found: /lib/modules/3.4.0-gentoo/build/net/9p/9pnet.ko
found: /lib/modules/3.4.0-gentoo/kernel/fs/9p/9p.ko
found: /lib/modules/3.4.0-gentoo/source/fs/9p/9p.ko
found: /lib/modules/3.4.0-gentoo/build/fs/9p/9p.ko
found: /lib/modules/3.4.0-gentoo/kernel/net/9p/9pnet_virtio.ko
found: /lib/modules/3.4.0-gentoo/source/net/9p/9pnet_virtio.ko
found: /lib/modules/3.4.0-gentoo/build/net/9p/9pnet_virtio.ko
The next problem was the following:
dmns libvirt-sandbox # virt-sandbox -c qemu:///system -n test123 -v -d
/usr/bin/yes
Unable to start sandbox: Failed to create domain: internal error
Process exited while reading console log output: char device
redirected to /dev/pts/1
char device redirected to /dev/pts/3
Virtio-9p Failed to initialize fs-driver with id:fsdev-fs1 and export
path:libvirt-sandbox/test123/config
It appears when running as root because of the following line:
./libvirt-sandbox/libvirt-sandbox-context.c: cachedir = (getuid() ? g_get_user_cache_dir() : RUNDIR);
RUNDIR is always "" due to being compiled with -DRUNDIR=\"\" . This is because there's a typo in makefile.am
Both of these are fixed in the diff attachment.
Having these fixes in place everything works fine when using libvirt 0.9.10 but for newer versions I noticed every time I ran virt-sandbox the libvirtd daemon would segfault.
Using git bisect I traced the problem back to commit [1]. So I reverted back to libvirt 0.9.10 but I believe there is a problem both in the commit and somewhere in libvirt-sandbox.
Please have a look and tell me if you need extra info.
[1] http://libvirt.org/git/?p=libvirt.git;a=commit;h=4716138229ae47c5492c1...
Radu Caragea.
12 years, 6 months
Re: [libvirt] Error while installing a guest
by Pankaj Rawat
I am attaching the virtinstall log file is attached
Regards
Pankaj Rawat
From: Pankaj Rawat
Sent: Tuesday, June 12, 2012 3:26 PM
To: Alex Jia
Cc: libvir-list(a)redhat.com
Subject: RE: [libvirt] Error while installing a guest
Ok I am attaching the file.
Regards
Pankaj Rawat
-----Original Message-----
From: Alex Jia [mailto:ajia@redhat.com]
Sent: Tuesday, June 12, 2012 11:38 AM
To: Pankaj Rawat
Cc: libvir-list(a)redhat.com
Subject: Re: [libvirt] Error while installing a guest
Hi Pankaj,
Could you attach your virt-install.log as an attachment?
it locals in ~/.virtinst/virt-install.log.
Or Is it okay if you also upgrade your python-virtinst?
Thanks,
Alex
----- Original Message -----
From: "Pankaj Rawat" <pankaj.rawat(a)nechclst.in>
To: libvir-list(a)redhat.com
Sent: Tuesday, June 12, 2012 1:56:05 PM
Subject: [libvirt] Error while installing a guest
Hi all ,
I have SL6.2 x86_64 Installed on my system
I updated libvirt version from 0.9.4 to 0.9.11, I had removed previous libvirt via yum
I done this by compiling the source.
I started libvirt daemon created by compiling source :
# ./root/libvirt_0.9.11/build/daomen/libvirtd
Now I tried to create a guest:-
[root@localhost libvirt-0.9.11]# /usr/sbin/virt-install --accelerate --hvm --connect qemu:///system --name g3 --vcpu=1 --ram 1024 --os-type=linux --os-variant=rhel6 --network bridge:br0 --disk /var/lib/libvirt/images/g2 --disk=/opt/SL-62-x86_64-2012-02-06-Install-DVD.iso,device=cdrom,perms=ro --location=/mnt/ --nographics --serial pty --extra-args=console=ttyS0,115200n8 --keymap=en --force
The command line above normally works fine (I have created many vm by using same above command)
But here Following error comes
Starting install...
Retrieving file .treeinfo... | 768 B 00:00 ...
Retrieving file vmlinuz... | 7.5 MB 00:00 ...
Retrieving file initrd.img... 100% [=====================================================] 11 MB/s | 29 MB --:-- ETA
Retrieving file initrd.img... | 59 MB 00:09 ...
ERROR internal error Process exited while reading console log output:
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start g3
otherwise, please restart your installation.
at libvirtd console following output comes:
2012-06-12 13:58:55.239+0000: 17800: error : qemuProcessReadLogOutput:1298 : internal error Process exited while reading console log output:
2012-06-12 14:04:12.120+0000: 17802: warning : qemuDomainObjTaint:1227 : Domain id=3 name='g3' uuid=fec6cb5a-d4ea-d2c9-505c-611227fb4f4c is tainted: high-privileges
2012-06-12 13:58:55.239+0000: 17800: error : qemuProcessReadLogOutput:1298 : internal error Process exited while reading console lo
I dont know how to resolve this .
Regards
Pankaj Rawat
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
12 years, 6 months
Re: [libvirt] Error while installing a guest
by Alex Jia
On 06/12/2012 05:55 PM, Pankaj Rawat wrote:
>
>
> Ok I am attaching the file.
>
Please check your guest image size by qemu-img info or ll -h, for
example: qemu-img info /var/lib/libvirt/images/g2,
and run 'ifconfig | grep br0' then paste output in here, thanks.
In addition, you may also use interactive virt-install to install a
guest with --prompt option then step by step.
>
> Regards
> Pankaj Rawat
>
>
> -----Original Message-----
> From: Alex Jia [mailto:ajia@redhat.com]
> Sent: Tuesday, June 12, 2012 11:38 AM
> To: Pankaj Rawat
> Cc: libvir-list(a)redhat.com
> Subject: Re: [libvirt] Error while installing a guest
>
> Hi Pankaj,
> Could you attach your virt-install.log as an attachment?
> it locals in ~/.virtinst/virt-install.log.
>
> Or Is it okay if you also upgrade your python-virtinst?
>
> Thanks,
> Alex
>
>
> ----- Original Message -----
> From: "Pankaj Rawat" <pankaj.rawat(a)nechclst.in>
> To: libvir-list(a)redhat.com
> Sent: Tuesday, June 12, 2012 1:56:05 PM
> Subject: [libvirt] Error while installing a guest
>
>
>
>
>
> Hi all ,
>
> I have SL6.2 x86_64 Installed on my system
>
> I updated libvirt version from 0.9.4 to 0.9.11, I had removed previous
> libvirt via yum
>
> I done this by compiling the source.
>
>
>
> I started libvirt daemon created by compiling source :
>
> # ./root/libvirt_0.9.11/build/daomen/libvirtd
>
>
>
> Now I tried to create a guest:-
>
> [root@localhost libvirt-0.9.11]# /usr/sbin/virt-install --accelerate
> --hvm --connect qemu:///system --name g3 --vcpu=1 --ram 1024
> --os-type=linux --os-variant=rhel6 --network bridge:br0 --disk
> /var/lib/libvirt/images/g2
> --disk=/opt/SL-62-x86_64-2012-02-06-Install-DVD.iso,device=cdrom,perms=ro
> --location=/mnt/ --nographics --serial pty
> --extra-args=console=ttyS0,115200n8 --keymap=en --force
>
>
>
> The command line above normally works fine (I have created many vm by
> using same above command)
>
>
>
> But here Following error comes
>
> Starting install...
> Retrieving file .treeinfo... | 768 B 00:00 ...
> Retrieving file vmlinuz... | 7.5 MB 00:00 ...
> Retrieving file initrd.img... 100%
> [=====================================================] 11 MB/s | 29
> MB --:-- ETA
>
> Retrieving file initrd.img... | 59 MB 00:09 ...
> ERROR internal error Process exited while reading console log output:
> Domain installation does not appear to have been successful.
> If it was, you can restart your domain by running:
> virsh --connect qemu:///system start g3
> otherwise, please restart your installation.
>
> at libvirtd console following output comes:
> 2012-06-12 13:58:55.239+0000: 17800: error :
> qemuProcessReadLogOutput:1298 : internal error Process exited while
> reading console log output:
> 2012-06-12 14:04:12.120+0000: 17802: warning : qemuDomainObjTaint:1227
> : Domain id=3 name='g3' uuid=fec6cb5a-d4ea-d2c9-505c-611227fb4f4c is
> tainted: high-privileges
> 2012-06-12 13:58:55.239+0000: 17800: error :
> qemuProcessReadLogOutput:1298 : internal error Process exited while
> reading console lo
>
>
>
> I dont know how to resolve this .
>
> Regards
>
> Pankaj Rawat
>
> DISCLAIMER:
>
> -----------------------------------------------------------------------------------------------------------------------
>
>
> The contents of this e-mail and any attachment(s) are confidential and
> intended
>
> for the named recipient(s) only.
>
> It shall not attach any liability on the originator or NECHCL or its
>
> affiliates. Any views or opinions presented in
>
> this email are solely those of the author and may not necessarily
> reflect the
>
> opinions of NECHCL or its affiliates.
>
> Any form of reproduction, dissemination, copying, disclosure,
> modification,
>
> distribution and / or publication of
>
> this message without the prior written consent of the author of this
> e-mail is
>
> strictly prohibited. If you have
>
> received this email in error please delete it and notify the sender
>
> immediately. .
>
> -----------------------------------------------------------------------------------------------------------------------
>
> --
> libvir-list mailing list
> libvir-list(a)redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
> DISCLAIMER:
>
> -----------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachment(s) are confidential and
> intended
>
> for the named recipient(s) only.
>
> It shall not attach any liability on the originator or NECHCL or its
>
> affiliates. Any views or opinions presented in
>
> this email are solely those of the author and may not necessarily reflect the
>
> opinions of NECHCL or its affiliates.
>
> Any form of reproduction, dissemination, copying, disclosure, modification,
>
> distribution and / or publication of
>
> this message without the prior written consent of the author of this e-mail is
>
> strictly prohibited. If you have
>
> received this email in error please delete it and notify the sender
>
> immediately. .
>
> -----------------------------------------------------------------------------------------------------------------------
12 years, 6 months
[libvirt] [PATCH 0/2] Don't overwrite security labels
by Michal Privoznik
If we have a running domain A with a PCI/USB device X passthrough,
and user wants to start domain B with again device X, we
reject start however, call qemuProcessStop to perform rollback.
This however does not do any rollback just cleanup therefore
rewrite labels on device X leaving domain A in silly situation.
Michal Privoznik (2):
qemuProcessStop: Switch to flags
qemu: Don't overwrite security labels
src/qemu/qemu_driver.c | 16 ++++++++--------
src/qemu/qemu_migration.c | 20 +++++++++++++-------
src/qemu/qemu_process.c | 28 +++++++++++++++++-----------
src/qemu/qemu_process.h | 9 +++++++--
4 files changed, 45 insertions(+), 28 deletions(-)
--
1.7.8.5
12 years, 6 months
[libvirt] [PATCH] virsh: let 'connect' without args remember -c option
by Eric Blake
If a user invokes 'virsh -c $URI', then within that batch shell,
they probably want 'connect' to revert to $URI rather than the
normal default URI you get for passing in NULL.
In particular, I had a setup where qemu:///session was failing,
but took 20 seconds to fail; since 'make -C tests check TESTS=virsh-all'
exercises the command 'virsh -c test:///default connect' without
arguments, it was locking up for 20 seconds trying to connect to
qemu, even though the testsuite specifically wants to limit itself
to the test:///default URI.
* tools/virsh.c (__vshControl): Add member.
(main, vshParseArgv): Set it.
(vshDeinit): Clean it up.
(cmdConnect): Use it to reopen to original connection.
---
This doesn't fix the root cause of this problem:
https://www.redhat.com/archives/libvir-list/2012-June/msg00237.html
but at least it makes my 'make check' runs faster while
I still investigate the root problem.
tools/virsh.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 0453b95..b28dc49 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -241,6 +241,7 @@ typedef struct __vshCmd {
*/
typedef struct __vshControl {
char *name; /* connection name */
+ char *default_name; /* -c or env-var default when name is NULL */
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
vshCmd *cmd; /* the current command */
char *cmdstr; /* string with command */
@@ -856,7 +857,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("Please specify valid connection URI"));
return false;
}
- ctl->name = vshStrdup(ctl, name);
+ ctl->name = vshStrdup(ctl, name ? name : ctl->default_name);
ctl->useGetInfo = false;
ctl->useSnapshotOld = false;
@@ -19922,6 +19923,7 @@ vshDeinit(vshControl *ctl)
vshReadlineDeinit(ctl);
vshCloseLogFile(ctl);
VIR_FREE(ctl->name);
+ VIR_FREE(ctl->default_name);
if (ctl->conn) {
int ret;
if ((ret = virConnectClose(ctl->conn)) != 0) {
@@ -20176,7 +20178,8 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
ctl->timing = true;
break;
case 'c':
- ctl->name = vshStrdup(ctl, optarg);
+ VIR_FREE(ctl->default_name);
+ ctl->default_name = vshStrdup(ctl, optarg);
break;
case 'v':
if (STRNEQ_NULLABLE(optarg, "long")) {
@@ -20211,6 +20214,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
exit(EXIT_FAILURE);
}
}
+ ctl->name = vshStrdup(ctl, ctl->default_name);
if (argc > optind) {
/* parse command */
@@ -20268,7 +20272,7 @@ main(int argc, char **argv)
progname++;
if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {
- ctl->name = vshStrdup(ctl, defaultConn);
+ ctl->default_name = vshStrdup(ctl, defaultConn);
}
if (!vshParseArgv(ctl, argc, argv)) {
--
1.7.10.2
12 years, 6 months
[libvirt] [PATCH v3 1/2] virsh: add keepalive protocol in virsh
by Guannan Ren
Bugzilla:https://bugzilla.redhat.com/show_bug.cgi?id=822839
Add two general virsh options to start keepalive messaging in virsh
By default, virsh doesn't start keepalive.
Under the explicit request of keepalive with the the following options
, virsh will try to start keepalive. The virsh will fail if the keepalive
request cannot be honored.
error: this function is not supported by the connection driver: virConnectSetKeepAlive
error: Failed to connect to the hypervisor
-i | --keepalive_interval
interval time value
-n | --keepalive_count number of keepalive message
For non-p2p migration, start keepalive for remote driver to
determine the status of network connection, aborting migrating job
after defined amount of interval time.
---
tools/virsh.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++---------
tools/virsh.pod | 13 ++++++
2 files changed, 105 insertions(+), 18 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 744b629..33aeb6c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -251,6 +251,10 @@ typedef struct __vshControl {
bool readonly; /* connect readonly (first time only, not
* during explicit connect command)
*/
+ unsigned int keepalive_interval;
+ /* interval time value */
+ unsigned int keepalive_count;
+ /* keepalive_count value */
char *logfile; /* log file name */
int log_fd; /* log file descriptor */
char *historydir; /* readline history directory name */
@@ -415,13 +419,14 @@ typedef struct __vshCtrlData {
vshControl *ctl;
const vshCmd *cmd;
int writefd;
+ virConnectPtr dconn;
} vshCtrlData;
typedef void (*jobWatchTimeoutFunc) (vshControl *ctl, virDomainPtr dom,
void *opaque);
static bool
-vshWatchJob(vshControl *ctl,
+vshWatchJob(vshCtrlData *data,
virDomainPtr dom,
bool verbose,
int pipe_fd,
@@ -628,6 +633,39 @@ vshSetupSignals(void) {
}
/*
+ * vshConnectOpen:
+ *
+ * A wrapper for virConnectOpenAuth.
+ */
+static virConnectPtr
+vshConnectOpen(const char *name,
+ bool readonly,
+ vshControl *ctl)
+{
+ virConnectPtr conn;
+
+ if (!ctl)
+ return NULL;
+
+ conn = virConnectOpenAuth(name,
+ virConnectAuthPtrDefault,
+ readonly ? VIR_CONNECT_RO : 0);
+ if (!conn)
+ return NULL;
+
+ if (ctl->keepalive_interval > 0 && ctl->keepalive_count > 0)
+ if (virConnectSetKeepAlive(conn,
+ ctl->keepalive_interval,
+ ctl->keepalive_count) < 0) {
+ virshReportError(ctl);
+ virConnectClose(conn);
+ return NULL;
+ }
+
+ return conn;
+}
+
+/*
* vshReconnect:
*
* Reconnect after a disconnect from libvirtd
@@ -643,9 +681,8 @@ vshReconnect(vshControl *ctl)
virConnectClose(ctl->conn);
}
- ctl->conn = virConnectOpenAuth(ctl->name,
- virConnectAuthPtrDefault,
- ctl->readonly ? VIR_CONNECT_RO : 0);
+ ctl->conn = vshConnectOpen(ctl->name, ctl->readonly, ctl);
+
if (!ctl->conn)
vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
else if (connected)
@@ -862,8 +899,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
ctl->useSnapshotOld = false;
ctl->readonly = ro;
- ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault,
- ctl->readonly ? VIR_CONNECT_RO : 0);
+ ctl->conn = vshConnectOpen(ctl->name, ctl->readonly, ctl);
if (!ctl->conn)
vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
@@ -3334,6 +3370,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
data.ctl = ctl;
data.cmd = cmd;
data.writefd = p[1];
+ data.dconn = NULL;
if (virThreadCreate(&workerThread,
true,
@@ -3341,7 +3378,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
&data) < 0)
goto cleanup;
- ret = vshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Save"));
+ ret = vshWatchJob(&data, dom, verbose, p[0], 0, NULL, NULL, _("Save"));
virThreadJoin(&workerThread);
@@ -3608,6 +3645,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
data.ctl = ctl;
data.cmd = cmd;
data.writefd = p[1];
+ data.dconn = NULL;
if (virThreadCreate(&workerThread,
true,
@@ -3615,7 +3653,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
&data) < 0)
goto cleanup;
- ret = vshWatchJob(ctl, dom, verbose, p[0], 0,
+ ret = vshWatchJob(&data, dom, verbose, p[0], 0,
NULL, NULL, _("Managedsave"));
virThreadJoin(&workerThread);
@@ -4086,6 +4124,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
data.ctl = ctl;
data.cmd = cmd;
data.writefd = p[1];
+ data.dconn = NULL;
if (virThreadCreate(&workerThread,
true,
@@ -4093,7 +4132,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
&data) < 0)
goto cleanup;
- ret = vshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Dump"));
+ ret = vshWatchJob(&data, dom, verbose, p[0], 0, NULL, NULL, _("Dump"));
virThreadJoin(&workerThread);
@@ -7210,9 +7249,16 @@ doMigrate (void *opaque)
virConnectPtr dconn = NULL;
virDomainPtr ddom = NULL;
- dconn = virConnectOpenAuth (desturi, virConnectAuthPtrDefault, 0);
+ dconn = vshConnectOpen(desturi, 0, ctl);
if (!dconn) goto out;
+ if (virConnectIsAlive(dconn) <= 0) {
+ virConnectClose(dconn);
+ goto out;
+ } else {
+ data->dconn = dconn;
+ }
+
ddom = virDomainMigrate2(dom, dconn, xml, flags, dname, migrateuri, 0);
if (ddom) {
virDomainFree(ddom);
@@ -7268,7 +7314,7 @@ vshMigrationTimeout(vshControl *ctl,
}
static bool
-vshWatchJob(vshControl *ctl,
+vshWatchJob(vshCtrlData *data,
virDomainPtr dom,
bool verbose,
int pipe_fd,
@@ -7286,6 +7332,7 @@ vshWatchJob(vshControl *ctl,
char retchar;
bool functionReturn = false;
sigset_t sigmask, oldsigmask;
+ vshControl *ctl = data->ctl;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGINT);
@@ -7329,6 +7376,13 @@ repoll:
goto cleanup;
}
+ if (data->dconn && virConnectIsAlive(data->dconn) <= 0) {
+ virDomainAbortJob(dom);
+ vshError(ctl, "%s",
+ _("Lost connection to destination host"));
+ goto cleanup;
+ }
+
GETTIMEOFDAY(&curr);
if (timeout && (((int)(curr.tv_sec - start.tv_sec) * 1000 +
(int)(curr.tv_usec - start.tv_usec) / 1000) >
@@ -7402,13 +7456,14 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
data.ctl = ctl;
data.cmd = cmd;
data.writefd = p[1];
+ data.dconn = NULL;
if (virThreadCreate(&workerThread,
true,
doMigrate,
&data) < 0)
goto cleanup;
- functionReturn = vshWatchJob(ctl, dom, verbose, p[0], timeout,
+ functionReturn = vshWatchJob(&data, dom, verbose, p[0], timeout,
vshMigrationTimeout, NULL, _("Migration"));
virThreadJoin(&workerThread);
@@ -19658,9 +19713,7 @@ vshInit(vshControl *ctl)
ctl->eventLoopStarted = true;
if (ctl->name) {
- ctl->conn = virConnectOpenAuth(ctl->name,
- virConnectAuthPtrDefault,
- ctl->readonly ? VIR_CONNECT_RO : 0);
+ ctl->conn = vshConnectOpen(ctl->name, ctl->readonly, ctl);
/* Connecting to a named connection must succeed, but we delay
* connecting to the default connection until we need it
@@ -19670,7 +19723,7 @@ vshInit(vshControl *ctl)
*/
if (!ctl->conn) {
virshReportError(ctl);
- vshError(ctl, "%s", _("failed to connect to the hypervisor"));
+ vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
return false;
}
}
@@ -20107,7 +20160,10 @@ vshUsage(void)
" -v short version\n"
" -V long version\n"
" --version[=TYPE] version, TYPE is short or long (default short)\n"
- " -e | --escape <char> set escape sequence for console\n\n"
+ " -e | --escape <char> set escape sequence for console\n"
+ " -i | --keepalive_interval\n"
+ " interval time value \n"
+ " -n | --keepalive_count number of keepalive message\n\n"
" commands (non interactive mode):\n\n"), progname, progname);
for (grp = cmdGroups; grp->name; grp++) {
@@ -20284,13 +20340,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
{"readonly", no_argument, NULL, 'r'},
{"log", required_argument, NULL, 'l'},
{"escape", required_argument, NULL, 'e'},
+ {"keepalive_interval", required_argument, NULL, 'i'},
+ {"keepalive_count", required_argument, NULL, 'n'},
{NULL, 0, NULL, 0}
};
/* Standard (non-command) options. The leading + ensures that no
* argument reordering takes place, so that command options are
* not confused with top-level virsh options. */
- while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) != -1) {
+ while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:i:n:", opt, NULL)) != -1) {
switch (arg) {
case 'd':
if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
@@ -20339,6 +20397,20 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
exit(EXIT_FAILURE);
}
break;
+ case 'i':
+ if (virStrToLong_ui(optarg, NULL, 10, &ctl->keepalive_interval) < 0) {
+ vshError(ctl,
+ "%s", _("option -i takes a non-negative numeric argument"));
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'n':
+ if (virStrToLong_ui(optarg, NULL, 10, &ctl->keepalive_count) < 0) {
+ vshError(ctl,
+ "%s", _("option -n takes a non-negative numeric argument"));
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
vshError(ctl, _("unsupported option '-%c'. See --help."), arg);
exit(EXIT_FAILURE);
@@ -20370,6 +20442,8 @@ main(int argc, char **argv)
ctl->log_fd = -1; /* Initialize log file descriptor */
ctl->debug = VSH_DEBUG_DEFAULT;
ctl->escapeChar = CTRL_CLOSE_BRACKET;
+ ctl->keepalive_interval = -1;
+ ctl->keepalive_count = 0;
if (!setlocale(LC_ALL, "")) {
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 6553825..faa97a2 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -98,6 +98,19 @@ Set alternative escape sequence for I<console> command. By default,
telnet's B<^]> is used. Allowed characters when using hat notation are:
alphabetic character, @, [, ], \, ^, _.
+=item B<-i>, B<--keepalive_interval> I<second>
+
+Use together with I<--keepalive_count> to start keepalive messaging between
+libvirt client and server. A keepalive message will be sent to a libvirt server
+after I<--keepalive_interval> seconds of inactivity to check if server is still
+responding. I<seconds> with 0 value has the same effect as without using this
+option.
+
+=item B<-n>, B<--keepalive_count> I<number>
+The maximum number of keepalive messages that are allowed to be sent to libvirt
+server without getting any response before the connection is considered broken.
+I<number> with 0 value has the same effect as without using this option.
+
=back
=head1 NOTES
--
1.7.7.5
12 years, 6 months