qemu_command.h 9.6 KB
Newer Older
1 2 3
/*
 * qemu_command.h: QEMU command generation
 *
4
 * Copyright (C) 2006-2012 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 27 28 29 30
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __QEMU_COMMAND_H__
# define __QEMU_COMMAND_H__

# include "domain_conf.h"
# include "command.h"
# include "capabilities.h"
# include "qemu_conf.h"
31
# include "qemu_domain.h"
32
# include "qemu_capabilities.h"
33 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_VIRTIO_SERIAL_PREFIX "virtio-serial"
# define QEMU_FSDEV_HOST_PREFIX "fsdev-"

41 42 43 44 45 46 47
/* These are only defaults, they can be changed now in qemu.conf and
 * explicitely specified port is checked against these two (makes
 * 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 54
virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
                                   struct qemud_driver *driver,
                                   virDomainDefPtr def,
55
                                   virDomainChrSourceDefPtr monitor_chr,
56
                                   bool monitor_json,
57
                                   qemuCapsPtr caps,
58
                                   const char *migrateFrom,
59
                                   int migrateFd,
60
                                   virDomainSnapshotObjPtr current_snapshot,
61
                                   enum virNetDevVPortProfileOp vmop)
62 63
    ATTRIBUTE_NONNULL(1);

64 65 66
/* Generate string for arch-specific '-device' parameter */
char *
qemuBuildChrDeviceStr (virDomainChrDefPtr serial,
67
                       qemuCapsPtr caps,
68 69 70
                       char *os_arch,
                       char *machine);

71 72
/* With vlan == -1, use netdev syntax, else old hostnet */
char * qemuBuildHostNetStr(virDomainNetDefPtr net,
R
Richa Marwaha 已提交
73
                           struct qemud_driver *driver,
74
                           qemuCapsPtr caps,
75 76 77 78 79 80 81 82 83 84 85 86
                           char type_sep,
                           int vlan,
                           const char *tapfd,
                           const char *vhostfd);

/* Legacy, pre device support */
char * qemuBuildNicStr(virDomainNetDefPtr net,
                       const char *prefix,
                       int vlan);

/* Current, best practice */
char * qemuBuildNicDevStr(virDomainNetDefPtr net,
87
                          int vlan,
88
                          int bootindex,
89
                          qemuCapsPtr caps);
90 91

char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
92
                               qemuCapsPtr caps);
93 94

/* Both legacy & current support */
95 96
char *qemuBuildDriveStr(virConnectPtr conn,
                        virDomainDiskDefPtr disk,
97
                        bool bootable,
98
                        qemuCapsPtr caps);
99
char *qemuBuildFSStr(virDomainFSDefPtr fs,
100
                     qemuCapsPtr caps);
101 102

/* Current, best practice */
103 104
char * qemuBuildDriveDevStr(virDomainDefPtr def,
                            virDomainDiskDefPtr disk,
105
                            int bootindex,
106
                            qemuCapsPtr caps);
107
char * qemuBuildFSDevStr(virDomainFSDefPtr fs,
108
                         qemuCapsPtr caps);
109
/* Current, best practice */
110 111
char * qemuBuildControllerDevStr(virDomainDefPtr domainDef,
                                 virDomainControllerDefPtr def,
112
                                 qemuCapsPtr caps,
113
                                 int *nusbcontroller);
114

115
char * qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev,
116
                               qemuCapsPtr caps);
117

118
char * qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev,
119
                                 qemuCapsPtr caps);
120

121
char * qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
122
                               qemuCapsPtr caps);
123

124
char * qemuBuildSoundDevStr(virDomainSoundDefPtr sound,
125
                            qemuCapsPtr caps);
126 127 128 129 130

/* Legacy, pre device support */
char * qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev);
/* Current, best practice */
char * qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev,
131
                                 const char *configfd,
132
                                 qemuCapsPtr caps);
133 134 135 136 137 138

int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

/* Legacy, pre device support */
char * qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev);
/* Current, best practice */
139
char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
140
                                 qemuCapsPtr caps);
141

142
char * qemuBuildHubDevStr(virDomainHubDefPtr dev, qemuCapsPtr caps);
143 144
char * qemuBuildRedirdevDevStr(virDomainDefPtr def,
                               virDomainRedirdevDefPtr dev,
145
                               qemuCapsPtr caps);
146

147 148
int qemuNetworkIfaceConnect(virDomainDefPtr def,
                            virConnectPtr conn,
149 150
                            struct qemud_driver *driver,
                            virDomainNetDefPtr net,
151
                            qemuCapsPtr caps)
152
    ATTRIBUTE_NONNULL(2);
153

154
int qemuPhysIfaceConnect(virDomainDefPtr def,
155 156
                         struct qemud_driver *driver,
                         virDomainNetDefPtr net,
157
                         qemuCapsPtr caps,
158
                         enum virNetDevVPortProfileOp vmop);
159

160 161
int qemuOpenVhostNet(virDomainDefPtr def,
                     virDomainNetDefPtr net,
162
                     qemuCapsPtr caps,
163 164
                     int *vhostfd);

165 166 167 168
/*
 * NB: def->name can be NULL upon return and the caller
 * *must* decide how to fill in a name in this case
 */
169 170
virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
                                     const char **progenv,
171 172 173 174
                                     const char **progargv,
                                     char **pidfile,
                                     virDomainChrSourceDefPtr *monConfig,
                                     bool *monJSON);
175
virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
176 177 178 179
                                           const char *args,
                                           char **pidfile,
                                           virDomainChrSourceDefPtr *monConfig,
                                           bool *monJSON);
180
virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
181
                                        pid_t pid,
182 183 184
                                        char **pidfile,
                                        virDomainChrSourceDefPtr *monConfig,
                                        bool *monJSON);
185

186
int qemuDomainAssignAddresses(virDomainDefPtr def,
187
                              qemuCapsPtr caps,
188 189
                              virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
190
int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
191
                                      qemuCapsPtr caps);
192

193
int qemuDomainAssignPCIAddresses(virDomainDefPtr def,
194
                                 qemuCapsPtr caps,
195
                                 virDomainObjPtr obj);
196
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
197 198
int qemuDomainPCIAddressReserveFunction(qemuDomainPCIAddressSetPtr addrs,
                                        int slot, int function);
199 200 201 202 203 204 205 206 207 208
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
                                    int slot);
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
                                   virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
209 210
int qemuDomainPCIAddressReleaseFunction(qemuDomainPCIAddressSetPtr addrs,
                                        int slot, int function);
211
int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot);
212 213 214 215

void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs);
int  qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs);

216
int qemuAssignDeviceAliases(virDomainDefPtr def, qemuCapsPtr caps);
217 218
int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx);
219 220
int qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef,
                              virDomainDiskDefPtr def,
221
                              qemuCapsPtr caps);
222
int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev, int idx);
223
int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller);
224
int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, int idx);
225 226 227 228 229 230 231 232 233

int
qemuParseKeywords(const char *str,
                  char ***retkeywords,
                  char ***retvalues,
                  int allowEmptyValue);


#endif /* __QEMU_COMMAND_H__*/