qemu_command.h 11.2 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 31
# include "capabilities.h"
# include "qemu_conf.h"
32
# include "qemu_domain.h"
33
# include "qemu_capabilities.h"
34 35 36 37 38 39 40

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

# define QEMU_DRIVE_HOST_PREFIX "drive-"
# define QEMU_FSDEV_HOST_PREFIX "fsdev-"

41
/* These are only defaults, they can be changed now in qemu.conf and
N
Nehal J Wani 已提交
42
 * explicitly specified port is checked against these two (makes
43 44 45 46 47
 * sense to limit the values).
 *
 * This limitation is mentioned in qemu.conf, so bear in mind that the
 * configuration file should reflect any changes made to these values.
 */
48 49
# define QEMU_REMOTE_PORT_MIN  5900
# define QEMU_REMOTE_PORT_MAX  65535
50

51 52 53
# define QEMU_WEBSOCKET_PORT_MIN  5700
# define QEMU_WEBSOCKET_PORT_MAX  65535

54 55 56
# define QEMU_MIGRATION_PORT_MIN 49152
# define QEMU_MIGRATION_PORT_MAX 49215

57
VIR_ENUM_DECL(qemuVideo)
58

59 60 61
typedef struct _qemuBuildCommandLineCallbacks qemuBuildCommandLineCallbacks;
typedef qemuBuildCommandLineCallbacks *qemuBuildCommandLineCallbacksPtr;
struct _qemuBuildCommandLineCallbacks {
62 63 64 65
    char *(*qemuGetSCSIDeviceSgName) (const char *sysfs_prefix,
                                      const char *adapter,
                                      unsigned int bus,
                                      unsigned int target,
66
                                      unsigned long long unit);
67 68 69
};

extern qemuBuildCommandLineCallbacks buildCommandLineCallbacks;
70

71 72 73 74
char *qemuBuildObjectCommandlineFromJSON(const char *type,
                                         const char *alias,
                                         virJSONValuePtr props);

75
virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
76
                                   virQEMUDriverPtr driver,
77
                                   virDomainDefPtr def,
78
                                   virDomainChrSourceDefPtr monitor_chr,
79
                                   bool monitor_json,
80
                                   virQEMUCapsPtr qemuCaps,
81
                                   const char *migrateURI,
82
                                   virDomainSnapshotObjPtr current_snapshot,
83
                                   virNetDevVPortProfileOp vmop,
C
Cole Robinson 已提交
84
                                   qemuBuildCommandLineCallbacksPtr callbacks,
85
                                   bool forXMLToArgv,
86
                                   bool enableFips,
87 88 89
                                   virBitmapPtr nodeset,
                                   size_t *nnicindexes,
                                   int **nicindexes)
90
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(10);
91

92 93 94 95 96 97
/* Generate '-device' string for chardev device */
int
qemuBuildChrDeviceStr(char **deviceStr,
                      virDomainDefPtr vmdef,
                      virDomainChrDefPtr chr,
                      virQEMUCapsPtr qemuCaps);
98

99
/* With vlan == -1, use netdev syntax, else old hostnet */
100 101 102 103 104
char *qemuBuildHostNetStr(virDomainNetDefPtr net,
                          virQEMUDriverPtr driver,
                          char type_sep,
                          int vlan,
                          char **tapfd,
105
                          size_t tapfdSize,
106
                          char **vhostfd,
107
                          size_t vhostfdSize);
108 109

/* Legacy, pre device support */
110 111 112
char *qemuBuildNicStr(virDomainNetDefPtr net,
                      const char *prefix,
                      int vlan);
113 114

/* Current, best practice */
115 116 117 118
char *qemuBuildNicDevStr(virDomainDefPtr def,
                         virDomainNetDefPtr net,
                         int vlan,
                         int bootindex,
119
                         size_t vhostfdSize,
120
                         virQEMUCapsPtr qemuCaps);
121 122

char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
123
                               virQEMUCapsPtr qemuCaps);
124 125

/* Both legacy & current support */
126 127
char *qemuBuildDriveStr(virConnectPtr conn,
                        virDomainDiskDefPtr disk,
128
                        bool bootable,
129
                        virQEMUCapsPtr qemuCaps);
130
char *qemuBuildFSStr(virDomainFSDefPtr fs,
131
                     virQEMUCapsPtr qemuCaps);
132 133

/* Current, best practice */
134 135 136 137 138 139 140
char *qemuBuildDriveDevStr(virDomainDefPtr def,
                           virDomainDiskDefPtr disk,
                           int bootindex,
                           virQEMUCapsPtr qemuCaps);
char *qemuBuildFSDevStr(virDomainDefPtr domainDef,
                        virDomainFSDefPtr fs,
                        virQEMUCapsPtr qemuCaps);
141
/* Current, best practice */
142 143 144 145
char *qemuBuildControllerDevStr(virDomainDefPtr domainDef,
                                virDomainControllerDefPtr def,
                                virQEMUCapsPtr qemuCaps,
                                int *nusbcontroller);
146

147 148 149
char *qemuBuildWatchdogDevStr(virDomainDefPtr domainDef,
                              virDomainWatchdogDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
150

151 152 153
char *qemuBuildMemballoonDevStr(virDomainDefPtr domainDef,
                                virDomainMemballoonDefPtr dev,
                                virQEMUCapsPtr qemuCaps);
154

155 156 157
char *qemuBuildUSBInputDevStr(virDomainDefPtr domainDef,
                              virDomainInputDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
158

159 160 161
char *qemuBuildSoundDevStr(virDomainDefPtr domainDef,
                           virDomainSoundDefPtr sound,
                           virQEMUCapsPtr qemuCaps);
162

163 164 165 166 167 168 169 170 171 172 173 174
int qemuBuildMemoryBackendStr(unsigned long long size,
                              unsigned long long pagesize,
                              int guestNode,
                              virBitmapPtr userNodeset,
                              virBitmapPtr autoNodeset,
                              virDomainDefPtr def,
                              virQEMUCapsPtr qemuCaps,
                              virQEMUDriverConfigPtr cfg,
                              const char **backendType,
                              virJSONValuePtr *backendProps,
                              bool force);

175
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
176

177
/* Legacy, pre device support */
178 179
char *qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev,
                                   virQEMUCapsPtr qemuCaps);
180
/* Current, best practice */
181 182
char *qemuBuildPCIHostdevDevStr(virDomainDefPtr def,
                                virDomainHostdevDefPtr dev,
183
                                int bootIndex,
184 185
                                const char *configfd,
                                virQEMUCapsPtr qemuCaps);
186

187 188 189
char *qemuBuildRNGDevStr(virDomainDefPtr def,
                         virDomainRNGDefPtr dev,
                         virQEMUCapsPtr qemuCaps);
190 191 192 193
int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
                             virQEMUCapsPtr qemuCaps,
                             const char **type,
                             virJSONValuePtr *props);
194

195 196 197 198 199 200 201
char *qemuBuildShmemDevStr(virDomainDefPtr def,
                           virDomainShmemDefPtr shmem,
                           virQEMUCapsPtr qemuCaps);
char *qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem,
                               virQEMUCapsPtr qemuCaps);


202 203 204
int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

/* Legacy, pre device support */
205
char *qemuBuildUSBHostdevUSBDevStr(virDomainHostdevDefPtr dev);
206
/* Current, best practice */
207 208 209 210 211 212 213 214 215 216
char *qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
                                virDomainHostdevDefPtr dev,
                                virQEMUCapsPtr qemuCaps);

char *qemuBuildSCSIHostdevDrvStr(virConnectPtr conn,
                                 virDomainHostdevDefPtr dev,
                                 virQEMUCapsPtr qemuCaps,
                                 qemuBuildCommandLineCallbacksPtr callbacks)
    ATTRIBUTE_NONNULL(4);
char *qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
217
                                 virDomainHostdevDefPtr dev,
218
                                 virQEMUCapsPtr qemuCaps);
219

220 221 222 223 224 225
char *qemuBuildHubDevStr(virDomainDefPtr def,
                         virDomainHubDefPtr dev,
                         virQEMUCapsPtr qemuCaps);
char *qemuBuildRedirdevDevStr(virDomainDefPtr def,
                              virDomainRedirdevDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
226

227 228
int qemuOpenVhostNet(virDomainDefPtr def,
                     virDomainNetDefPtr net,
229
                     virQEMUCapsPtr qemuCaps,
230
                     int *vhostfd,
231
                     size_t *vhostfdSize);
232

233 234
int qemuNetworkPrepareDevices(virDomainDefPtr def);

235
int qemuDomainAssignAddresses(virDomainDefPtr def,
236
                              virQEMUCapsPtr qemuCaps,
237 238
                              virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
239
int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
240
                                      virQEMUCapsPtr qemuCaps);
241

242 243 244 245
void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
                                    virDomainDeviceInfoPtr info,
                                    const char *devstr);

246

247
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
248 249
int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx);
250 251
int qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef,
                              virDomainDiskDefPtr def,
252
                              virQEMUCapsPtr qemuCaps);
253
int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev, int idx);
254 255 256 257
int
qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
                                virQEMUCapsPtr qemuCaps,
                                virDomainControllerDefPtr controller);
258
int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, int idx);
259 260 261
int qemuAssignDeviceChrAlias(virDomainDefPtr def,
                             virDomainChrDefPtr chr,
                             ssize_t idx);
262
int qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng, size_t idx);
263

264 265 266
int qemuGetDriveSourceString(virStorageSourcePtr src,
                             virConnectPtr conn,
                             char **source);
267 268

int qemuCheckDiskConfig(virDomainDiskDefPtr disk);
269 270 271

bool
qemuCheckFips(void);
272 273 274 275 276

bool qemuCheckCCWS390AddressSupport(virDomainDefPtr def,
                                    virDomainDeviceInfo info,
                                    virQEMUCapsPtr qemuCaps,
                                    const char *devicename);
277

278
#endif /* __QEMU_COMMAND_H__*/