qemu_command.h 8.4 KB
Newer Older
1 2 3
/*
 * qemu_command.h: QEMU command generation
 *
4
 * Copyright (C) 2006-2016 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2006 Daniel P. Berrange
 *
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21 22 23 24 25 26
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __QEMU_COMMAND_H__
# define __QEMU_COMMAND_H__

27
# include "domain_addr.h"
28
# include "domain_conf.h"
29
# include "vircommand.h"
30
# include "capabilities.h"
31
# include "qemu_block.h"
32
# include "qemu_conf.h"
33
# include "qemu_domain.h"
34
# include "qemu_domain_address.h"
35
# include "qemu_capabilities.h"
36
# include "logging/log_manager.h"
37 38 39 40 41 42

/* Config type for XML import/export conversions */
# define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"

# define QEMU_FSDEV_HOST_PREFIX "fsdev-"

43 44
# define QEMU_BLOCK_IOTUNE_MAX 1000000000000000LL

45
VIR_ENUM_DECL(qemuVideo)
46

47
virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
48
                                   virLogManagerPtr logManager,
49
                                   virSecurityManagerPtr secManager,
50
                                   virDomainObjPtr vm,
51
                                   const char *migrateURI,
52
                                   virDomainSnapshotObjPtr snapshot,
53
                                   virNetDevVPortProfileOp vmop,
54
                                   bool standalone,
55
                                   bool enableFips,
56
                                   size_t *nnicindexes,
57
                                   int **nicindexes);
58

59
/* Generate the object properties for pr-manager */
60
virJSONValuePtr qemuBuildPRManagerInfoProps(virStorageSourcePtr src);
61
virJSONValuePtr qemuBuildPRManagedManagerInfoProps(qemuDomainObjPrivatePtr priv);
62

63 64 65 66
/* Generate the object properties for a secret */
int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
                             virJSONValuePtr *propsret);

67 68
/* Generate the object properties for a tls-creds-x509 */
int qemuBuildTLSx509BackendProps(const char *tlspath,
69
                                 bool isListen,
70
                                 bool verifypeer,
71
                                 const char *alias,
72
                                 const char *secalias,
73 74 75
                                 virQEMUCapsPtr qemuCaps,
                                 virJSONValuePtr *propsret);

76 77 78 79
/* Open a UNIX socket for chardev FD passing */
int
qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev);

80 81 82
/* Generate '-device' string for chardev device */
int
qemuBuildChrDeviceStr(char **deviceStr,
83
                      const virDomainDef *vmdef,
84 85
                      virDomainChrDefPtr chr,
                      virQEMUCapsPtr qemuCaps);
86

87 88 89
char *qemuBuildHostNetStr(virDomainNetDefPtr net,
                          virQEMUDriverPtr driver,
                          char **tapfd,
90
                          size_t tapfdSize,
91
                          char **vhostfd,
92
                          size_t vhostfdSize);
93 94

/* Current, best practice */
95
char *qemuBuildNicDevStr(virDomainDefPtr def,
96
                         virDomainNetDefPtr net,
97
                         unsigned int bootindex,
98
                         size_t vhostfdSize,
99
                         virQEMUCapsPtr qemuCaps);
100

101
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
102
bool qemuDiskBusNeedsDriveArg(int bus);
103

104 105
qemuBlockStorageSourceAttachDataPtr
qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
106
                                         virQEMUCapsPtr qemuCaps);
107 108
int
qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
109 110
                                          qemuBlockStorageSourceAttachDataPtr data,
                                          virQEMUCapsPtr qemuCaps);
111

112 113 114 115 116
char
*qemuBuildDiskDeviceStr(const virDomainDef *def,
                        virDomainDiskDefPtr disk,
                        unsigned int bootindex,
                        virQEMUCapsPtr qemuCaps);
117

118
/* Current, best practice */
119 120 121 122 123
int qemuBuildControllerDevStr(const virDomainDef *domainDef,
                              virDomainControllerDefPtr def,
                              virQEMUCapsPtr qemuCaps,
                              char **devstr,
                              int *nusbcontroller);
124

125
int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
126
                                const char *alias,
127 128 129 130 131 132
                                virQEMUDriverConfigPtr cfg,
                                virQEMUCapsPtr qemuCaps,
                                virDomainDefPtr def,
                                virDomainMemoryDefPtr mem,
                                virBitmapPtr autoNodeset,
                                bool force);
133

134
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
135

136
/* Current, best practice */
137
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
138
                                virDomainHostdevDefPtr dev,
139
                                unsigned int bootIndex,
140 141
                                const char *configfd,
                                virQEMUCapsPtr qemuCaps);
142

143
char *qemuBuildRNGDevStr(const virDomainDef *def,
144 145
                         virDomainRNGDefPtr dev,
                         virQEMUCapsPtr qemuCaps);
146 147 148
int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
                             virQEMUCapsPtr qemuCaps,
                             virJSONValuePtr *props);
149

150 151 152
int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

/* Current, best practice */
153
char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
154 155 156
                                virDomainHostdevDefPtr dev,
                                virQEMUCapsPtr qemuCaps);

157 158
char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
                                 virQEMUCapsPtr qemuCaps);
J
Ján Tomko 已提交
159

160
char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
161
                                 virDomainHostdevDefPtr dev);
162 163 164 165 166
char *
qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
                                virDomainHostdevDefPtr dev,
                                virQEMUCapsPtr qemuCaps,
                                char *vhostfdName);
167

168 169 170 171 172
char *
qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
                               virDomainHostdevDefPtr dev,
                               virQEMUCapsPtr qemuCaps);

173
char *qemuBuildRedirdevDevStr(const virDomainDef *def,
174 175
                              virDomainRedirdevDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
176

177 178
int qemuNetworkPrepareDevices(virDomainDefPtr def);

179
int qemuGetDriveSourceString(virStorageSourcePtr src,
180
                             qemuDomainSecretInfoPtr secinfo,
181
                             char **source);
182

183 184 185
bool
qemuDiskConfigBlkdeviotuneEnabled(virDomainDiskDefPtr disk);

186 187
int qemuCheckDiskConfig(virDomainDiskDefPtr disk,
                        virQEMUCapsPtr qemuCaps);
188 189 190

bool
qemuCheckFips(void);
191

192 193 194
virJSONValuePtr qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
    ATTRIBUTE_NONNULL(1);

195 196 197 198 199 200 201 202
virJSONValuePtr qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

char *qemuBuildShmemDevStr(virDomainDefPtr def,
                           virDomainShmemDefPtr shmem,
                           virQEMUCapsPtr qemuCaps)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

M
Michal Privoznik 已提交
203 204 205
char *qemuBuildWatchdogDevStr(const virDomainDef *def,
                              virDomainWatchdogDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
206

J
Ján Tomko 已提交
207 208 209 210 211 212 213
int qemuBuildInputDevStr(char **devstr,
                         const virDomainDef *def,
                         virDomainInputDefPtr input,
                         virQEMUCapsPtr qemuCaps)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4);

J
Ján Tomko 已提交
214 215 216 217 218 219 220 221
char *
qemuBuildVsockDevStr(virDomainDefPtr def,
                     virDomainVsockDefPtr vsock,
                     virQEMUCapsPtr qemuCaps,
                     const char *fdprefix)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4);

222
#endif /* __QEMU_COMMAND_H__*/