virsh.h 3.6 KB
Newer Older
E
Eric Blake 已提交
1 2 3
/*
 * virsh.h: a shell to exercise the libvirt API
 *
4
 * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
E
Eric Blake 已提交
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
17
 * License along with this library.  If not, see
E
Eric Blake 已提交
18 19 20 21 22 23 24 25
 * <http://www.gnu.org/licenses/>.
 *
 * Daniel Veillard <veillard@redhat.com>
 * Karel Zak <kzak@redhat.com>
 * Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef VIRSH_H
26
# define VIRSH_H
E
Eric Blake 已提交
27 28 29 30 31 32 33

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <stdarg.h>
# include <unistd.h>
# include <sys/stat.h>
34
# include <termios.h>
E
Eric Blake 已提交
35 36

# include "internal.h"
37
# include "virerror.h"
38
# include "virthread.h"
39
# include "vsh.h"
E
Eric Blake 已提交
40

41 42
# define VIRSH_PROMPT_RW    "virsh # "
# define VIRSH_PROMPT_RO    "virsh > "
E
Eric Blake 已提交
43 44 45 46 47 48

# define VIR_FROM_THIS VIR_FROM_NONE

/*
 * Command group types
 */
49 50 51 52 53 54 55 56 57 58 59 60
# 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"
E
Eric Blake 已提交
61

62 63
typedef struct _virshControl virshControl;
typedef virshControl *virshControlPtr;
E
Eric Blake 已提交
64

65
typedef struct _virshCtrlData virshCtrlData;
E
Eric Blake 已提交
66 67 68 69

/*
 * vshControl
 */
70
struct _virshControl {
E
Eric Blake 已提交
71 72 73 74 75 76 77 78
    virConnectPtr conn;         /* connection to hypervisor (MAY BE NULL) */
    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 */
79 80
    bool blockJobNoBytes;       /* true if _BANDWIDTH_BYTE blockjob flags
                                   are missing */
E
Eric Blake 已提交
81 82
    const char *escapeChar;     /* String representation of
                                   console escape character */
E
Eric Blake 已提交
83
};
E
Eric Blake 已提交
84 85 86 87 88

/* Typedefs, function prototypes for job progress reporting.
 * There are used by some long lingering commands like
 * migrate, dump, save, managedsave.
 */
89
struct _virshCtrlData {
E
Eric Blake 已提交
90 91 92
    vshControl *ctl;
    const vshCmd *cmd;
    int writefd;
93
    virConnectPtr dconn;
E
Eric Blake 已提交
94
};
E
Eric Blake 已提交
95

96 97 98 99 100 101 102
/* 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;
103

104 105
virConnectPtr virshConnect(vshControl *ctl, const char *uri, bool readonly);
int virshDomainState(vshControl *ctl, virDomainPtr dom, int *reason);
106

107 108
int virshStreamSink(virStreamPtr st, const char *bytes, size_t nbytes,
                    void *opaque);
109

E
Eric Blake 已提交
110
#endif /* VIRSH_H */