2012-08-18 03:16:04 +00:00
|
|
|
/*
|
|
|
|
* virsh.h: a shell to exercise the libvirt API
|
|
|
|
*
|
2015-02-19 13:16:39 +00:00
|
|
|
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
|
2012-08-18 03:16:04 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-08-18 03:16:04 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Daniel Veillard <veillard@redhat.com>
|
|
|
|
* Karel Zak <kzak@redhat.com>
|
|
|
|
* Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VIRSH_H
|
2012-08-20 10:17:26 +00:00
|
|
|
# define VIRSH_H
|
2012-08-18 03:16:04 +00:00
|
|
|
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <string.h>
|
|
|
|
# include <stdarg.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <sys/stat.h>
|
2013-08-29 08:36:00 +00:00
|
|
|
# include <termios.h>
|
2012-08-18 03:16:04 +00:00
|
|
|
|
|
|
|
# include "internal.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
# include "virerror.h"
|
2012-12-13 15:49:48 +00:00
|
|
|
# include "virthread.h"
|
2015-06-15 16:53:58 +00:00
|
|
|
# include "vsh.h"
|
2012-08-18 03:16:04 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
# define VIRSH_PROMPT_RW "virsh # "
|
|
|
|
# define VIRSH_PROMPT_RO "virsh > "
|
2012-08-18 03:16:04 +00:00
|
|
|
|
|
|
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command group types
|
|
|
|
*/
|
2015-06-15 16:53:58 +00:00
|
|
|
# define VIRSH_CMD_GRP_DOM_MANAGEMENT "Domain Management"
|
|
|
|
# define VIRSH_CMD_GRP_DOM_MONITORING "Domain Monitoring"
|
|
|
|
# define VIRSH_CMD_GRP_STORAGE_POOL "Storage Pool"
|
|
|
|
# define VIRSH_CMD_GRP_STORAGE_VOL "Storage Volume"
|
|
|
|
# define VIRSH_CMD_GRP_NETWORK "Networking"
|
|
|
|
# define VIRSH_CMD_GRP_NODEDEV "Node Device"
|
|
|
|
# define VIRSH_CMD_GRP_IFACE "Interface"
|
|
|
|
# define VIRSH_CMD_GRP_NWFILTER "Network Filter"
|
|
|
|
# define VIRSH_CMD_GRP_SECRET "Secret"
|
|
|
|
# define VIRSH_CMD_GRP_SNAPSHOT "Snapshot"
|
|
|
|
# define VIRSH_CMD_GRP_HOST_AND_HV "Host and Hypervisor"
|
|
|
|
# define VIRSH_CMD_GRP_VIRSH "Virsh itself"
|
2012-08-18 03:16:04 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
typedef struct _virshControl virshControl;
|
|
|
|
typedef virshControl *virshControlPtr;
|
2012-08-18 03:16:04 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
typedef struct _virshCtrlData virshCtrlData;
|
2012-08-18 03:16:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* vshControl
|
|
|
|
*/
|
2015-06-15 16:53:58 +00:00
|
|
|
struct _virshControl {
|
2012-08-18 03:16:04 +00:00
|
|
|
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
|
admin: Rename virAdmConnect to virAdmDaemon
virAdmConnect was named after virConnect, but after some discussions,
most of the APIs called will be working with remote daemon and starting
them virAdmDaemon will make more sense. Only possibly controversal name
is CloseCallback (de)registration, and connecting to the daemon (which
will still be Open/Close), but even this makes sense if one thinks about
the daemon being opened and closed, e.g. as file, etc.
This way all the APIs working with the daemon will start with
virAdmDaemon prefix, they will accept virAdmDaemonPtr as first parameter
and that will better suit with other namings as well (virDomain*,
virAdmServer*, etc.).
Because in virt-admin, the connection name does not refer to a struct
that would have a connect in its name, also adjust 'connname' in
clients. And because it is not used anywhere in the vsh code, move it
from there into each client.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-11-25 15:59:30 +00:00
|
|
|
char *connname; /* connection name */
|
2012-08-18 03:16:04 +00:00
|
|
|
bool readonly; /* connect readonly (first time only, not
|
|
|
|
* during explicit connect command)
|
|
|
|
*/
|
|
|
|
bool useGetInfo; /* must use virDomainGetInfo, since
|
|
|
|
virDomainGetState is not supported */
|
|
|
|
bool useSnapshotOld; /* cannot use virDomainSnapshotGetParent or
|
|
|
|
virDomainSnapshotNumChildren */
|
2014-08-28 23:39:25 +00:00
|
|
|
bool blockJobNoBytes; /* true if _BANDWIDTH_BYTE blockjob flags
|
|
|
|
are missing */
|
2012-08-18 03:16:04 +00:00
|
|
|
const char *escapeChar; /* String representation of
|
|
|
|
console escape character */
|
2012-08-18 04:35:13 +00:00
|
|
|
};
|
2012-08-18 03:16:04 +00:00
|
|
|
|
|
|
|
/* Typedefs, function prototypes for job progress reporting.
|
|
|
|
* There are used by some long lingering commands like
|
|
|
|
* migrate, dump, save, managedsave.
|
|
|
|
*/
|
2015-06-15 16:53:58 +00:00
|
|
|
struct _virshCtrlData {
|
2012-08-18 03:16:04 +00:00
|
|
|
vshControl *ctl;
|
|
|
|
const vshCmd *cmd;
|
|
|
|
int writefd;
|
cmdMigrate: move vshConnect before vshWatchJob
A possible fix to issue:
http://www.redhat.com/archives/libvir-list/2014-August/thread.html#00227
While doing migration on KVM host, found problem sometimes:
VM is already running on the target host and disappears from source
host, but 'virsh migrate' command line hangs, cannot exit normally.
If pressing "ENTER" key, it will exit.
The code hangs at tools/virsh-domain.c: cmdMigrate
->vshWatchJob->poll():
poll() is trying to select pipe_fd, which is used to receive message
from doMigrate thread. In debugging, found that doMigrate finishes
and at the end it does call safewrite() to write the retval ('0' or
'1') to pipe_fd, and the write is completed. But cmdMigrate poll()
cannot get the event. If pressing "ENTER" key, poll() can get the
event and select pipe_fd, then command line can exit.
In current code, authentication thread which is called by vshConnect
will use stdin, and at the same time, in cmdMigrate main process,
poll() is listening to stdin, that probably affect poll() to get
pipe_fd event. Better to move authentication before vshWatchJob. With
this change, above problem does not exist.
Signed-off-by: Chunyan Liu <cyliu@suse.com>
2014-08-08 08:44:36 +00:00
|
|
|
virConnectPtr dconn;
|
2012-08-18 04:35:13 +00:00
|
|
|
};
|
2012-08-18 03:16:04 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
/* Filter flags for various vshCommandOpt*By() functions */
|
|
|
|
typedef enum {
|
|
|
|
VIRSH_BYID = (1 << 1),
|
|
|
|
VIRSH_BYUUID = (1 << 2),
|
|
|
|
VIRSH_BYNAME = (1 << 3),
|
|
|
|
VIRSH_BYMAC = (1 << 4),
|
|
|
|
} virshLookupByFlags;
|
2015-03-26 10:01:35 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
virConnectPtr virshConnect(vshControl *ctl, const char *uri, bool readonly);
|
|
|
|
int virshDomainState(vshControl *ctl, virDomainPtr dom, int *reason);
|
2015-03-26 10:01:35 +00:00
|
|
|
|
2015-06-15 16:53:58 +00:00
|
|
|
int virshStreamSink(virStreamPtr st, const char *bytes, size_t nbytes,
|
|
|
|
void *opaque);
|
2015-03-26 10:01:35 +00:00
|
|
|
|
2012-08-18 03:16:04 +00:00
|
|
|
#endif /* VIRSH_H */
|