2009-11-03 13:59:18 -05:00
|
|
|
/*
|
|
|
|
* qemu_monitor_json.h: interaction with QEMU monitor console
|
|
|
|
*
|
2012-02-18 09:20:01 -07:00
|
|
|
* Copyright (C) 2006-2009, 2011-2012 Red Hat, Inc.
|
2009-11-03 13:59:18 -05:00
|
|
|
* 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
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef QEMU_MONITOR_JSON_H
|
2010-03-09 19:22:22 +01:00
|
|
|
# define QEMU_MONITOR_JSON_H
|
2009-11-03 13:59:18 -05:00
|
|
|
|
2010-03-09 19:22:22 +01:00
|
|
|
# include "internal.h"
|
2009-11-03 13:59:18 -05:00
|
|
|
|
2010-03-09 19:22:22 +01:00
|
|
|
# include "qemu_monitor.h"
|
2012-02-13 12:19:24 +01:00
|
|
|
# include "bitmap.h"
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
|
|
|
|
const char *data,
|
|
|
|
size_t len,
|
|
|
|
qemuMonitorMessagePtr msg);
|
|
|
|
|
2011-03-09 21:24:04 +01:00
|
|
|
int qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
|
|
|
|
const char *cmd,
|
|
|
|
int scm_fd,
|
|
|
|
char **reply);
|
|
|
|
|
2010-02-12 13:45:20 +00:00
|
|
|
int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon);
|
|
|
|
|
2012-02-13 12:19:24 +01:00
|
|
|
int qemuMonitorJSONCheckCommands(qemuMonitorPtr mon,
|
|
|
|
virBitmapPtr qemuCaps,
|
|
|
|
int *json_hmp);
|
2011-03-16 20:34:01 +01:00
|
|
|
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
|
|
|
|
virConnectPtr conn);
|
|
|
|
int qemuMonitorJSONStopCPUs(qemuMonitorPtr mon);
|
2011-09-27 11:42:04 +02:00
|
|
|
int qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
|
|
|
|
bool *running,
|
|
|
|
virDomainPausedReason *reason);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONSystemPowerdown(qemuMonitorPtr mon);
|
2011-06-15 17:49:58 +01:00
|
|
|
int qemuMonitorJSONSystemReset(qemuMonitorPtr mon);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
|
|
|
|
int **pids);
|
2011-06-17 15:31:45 +01:00
|
|
|
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
|
|
|
|
int *virtType);
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
|
2012-03-02 13:27:39 -07:00
|
|
|
unsigned long long *currmem);
|
2010-04-12 12:31:15 +01:00
|
|
|
int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
|
|
|
|
virDomainMemoryStatPtr stats,
|
|
|
|
unsigned int nr_stats);
|
2011-09-13 15:49:50 +02:00
|
|
|
int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
|
2012-01-18 22:01:30 +01:00
|
|
|
virHashTablePtr table);
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
|
2011-09-16 14:05:58 +02:00
|
|
|
const char *dev_name,
|
2009-11-03 13:59:18 -05:00
|
|
|
long long *rd_req,
|
|
|
|
long long *rd_bytes,
|
2011-09-05 16:22:17 +08:00
|
|
|
long long *rd_total_times,
|
2009-11-03 13:59:18 -05:00
|
|
|
long long *wr_req,
|
|
|
|
long long *wr_bytes,
|
2011-09-05 16:22:17 +08:00
|
|
|
long long *wr_total_times,
|
|
|
|
long long *flush_req,
|
|
|
|
long long *flush_total_times,
|
2009-11-03 13:59:18 -05:00
|
|
|
long long *errs);
|
2011-09-05 16:22:17 +08:00
|
|
|
int qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorPtr mon,
|
|
|
|
int *nparams);
|
2010-05-14 09:10:01 -04:00
|
|
|
int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
|
2011-09-16 14:05:58 +02:00
|
|
|
const char *dev_name,
|
2010-05-14 09:10:01 -04:00
|
|
|
unsigned long long *extent);
|
2011-11-29 15:34:53 +08:00
|
|
|
int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
|
|
|
|
const char *devce,
|
|
|
|
unsigned long long size);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
|
|
|
|
const char *password);
|
2011-01-10 12:12:32 +01:00
|
|
|
int qemuMonitorJSONSetPassword(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *password,
|
|
|
|
const char *action_if_connected);
|
|
|
|
int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *expire_time);
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONSetBalloon(qemuMonitorPtr mon,
|
|
|
|
unsigned long newmem);
|
2010-02-08 16:37:17 +00:00
|
|
|
int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, int cpu, int online);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
|
2011-09-16 14:05:58 +02:00
|
|
|
const char *dev_name,
|
2010-11-08 12:52:48 -05:00
|
|
|
bool force);
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
|
2011-09-16 14:05:58 +02:00
|
|
|
const char *dev_name,
|
2009-11-03 13:59:18 -05:00
|
|
|
const char *newmedia,
|
|
|
|
const char *format);
|
|
|
|
|
|
|
|
|
|
|
|
int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t length,
|
|
|
|
const char *path);
|
|
|
|
int qemuMonitorJSONSavePhysicalMemory(qemuMonitorPtr mon,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t length,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,
|
|
|
|
unsigned long bandwidth);
|
|
|
|
|
2010-03-17 16:53:14 +01:00
|
|
|
int qemuMonitorJSONSetMigrationDowntime(qemuMonitorPtr mon,
|
|
|
|
unsigned long long downtime);
|
|
|
|
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
|
|
|
|
int *status,
|
|
|
|
unsigned long long *transferred,
|
|
|
|
unsigned long long *remaining,
|
|
|
|
unsigned long long *total);
|
|
|
|
|
2011-03-04 11:51:48 -07:00
|
|
|
int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
|
|
|
|
unsigned int flags,
|
|
|
|
const char *uri);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
|
|
|
|
|
2011-02-17 13:39:36 +00:00
|
|
|
int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon,
|
|
|
|
int type,
|
|
|
|
const char *hostname,
|
|
|
|
int port,
|
|
|
|
int tlsPort,
|
|
|
|
const char *tlsSubject);
|
|
|
|
|
2009-11-03 13:59:18 -05:00
|
|
|
int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon,
|
|
|
|
int bus,
|
|
|
|
int dev);
|
|
|
|
int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|
|
|
int vendor,
|
|
|
|
int product);
|
|
|
|
|
|
|
|
|
|
|
|
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
2009-12-07 19:07:39 +00:00
|
|
|
virDomainDevicePCIAddress *hostAddr,
|
|
|
|
virDomainDevicePCIAddress *guestAddr);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
|
|
|
const char *path,
|
|
|
|
const char *bus,
|
2009-12-07 19:07:39 +00:00
|
|
|
virDomainDevicePCIAddress *guestAddr);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
|
|
|
const char *nicstr,
|
2009-12-07 19:07:39 +00:00
|
|
|
virDomainDevicePCIAddress *guestAddr);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
|
2009-12-07 19:07:39 +00:00
|
|
|
virDomainDevicePCIAddress *guestAddr);
|
2009-11-03 13:59:18 -05:00
|
|
|
|
|
|
|
int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
|
|
|
|
const char *fdname,
|
|
|
|
int fd);
|
|
|
|
|
|
|
|
int qemuMonitorJSONCloseFileHandle(qemuMonitorPtr mon,
|
|
|
|
const char *fdname);
|
|
|
|
|
|
|
|
int qemuMonitorJSONAddHostNetwork(qemuMonitorPtr mon,
|
|
|
|
const char *netstr);
|
|
|
|
|
|
|
|
int qemuMonitorJSONRemoveHostNetwork(qemuMonitorPtr mon,
|
|
|
|
int vlan,
|
|
|
|
const char *netname);
|
|
|
|
|
2010-04-15 14:52:03 +01:00
|
|
|
int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon,
|
|
|
|
const char *netdevstr);
|
|
|
|
|
|
|
|
int qemuMonitorJSONRemoveNetdev(qemuMonitorPtr mon,
|
|
|
|
const char *alias);
|
|
|
|
|
2010-01-22 13:22:53 +00:00
|
|
|
int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
|
|
|
|
virHashTablePtr paths);
|
|
|
|
|
2009-12-07 19:28:05 +00:00
|
|
|
int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon,
|
|
|
|
const char *bus,
|
|
|
|
virDomainDevicePCIAddress *guestAddr);
|
|
|
|
|
Properly support SCSI drive hotplug
The current SCSI hotplug support attaches a brand new SCSI controller
for every disk. This is broken because the semantics differ from those
used when starting the VM initially. In the latter case, each SCSI
controller is filled before a new one is added.
If the user specifies an high drive index (sdazz) then at initial
startup, many intermediate SCSI controllers may be added with no
drives.
This patch changes SCSI hotplug so that it exactly matches the
behaviour of initial startup. First the SCSI controller number is
determined for the drive to be hotplugged. If any controller upto
and including that controller number is not yet present, it is
attached. Then finally the drive is attached to the last controller.
NB, this breaks SCSI hotunplug, because there is no 'drive_del'
command in current QEMU. Previous SCSI hotunplug was broken in
any case because it was unplugging the entire controller, not
just the drive in question.
A future QEMU will allow proper SCSI hotunplug of a drive.
This patch is derived from work done by Wolfgang Mauerer on disk
controllers.
* src/qemu/qemu_driver.c: Fix SCSI hotplug to add a drive to
the correct controller, instead of just attaching a new
controller.
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
support for 'drive_add' command
2009-12-09 17:57:09 +00:00
|
|
|
int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
|
|
|
|
const char *drivestr,
|
|
|
|
virDomainDevicePCIAddress *controllerAddr,
|
|
|
|
virDomainDeviceDriveAddress *driveAddr);
|
|
|
|
|
Detect PCI addresses at QEMU startup
Hotunplug of devices requires that we know their PCI address. Even
hotplug of SCSI drives, required that we know the PCI address of
the SCSI controller to attach the drive to. We can find this out
by running 'info pci' and then correlating the vendor/product IDs
with the devices we booted with.
Although this approach is somewhat fragile, it is the only viable
option with QEMU < 0.12, since there is no way for libvirto set
explicit PCI addresses when creating devices in the first place.
For QEMU > 0.12, this code will not be used.
* src/qemu/qemu_driver.c: Assign all dynamic PCI addresses on
startup of QEMU VM, matching vendor/product IDs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
API for fetching PCI device address mapping
2009-12-09 21:59:04 +00:00
|
|
|
int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon,
|
|
|
|
qemuMonitorPCIAddress **addrs);
|
|
|
|
|
2010-01-26 15:34:46 +00:00
|
|
|
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
|
|
|
|
const char *devicestr);
|
|
|
|
|
2010-03-02 09:40:51 +01:00
|
|
|
int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
|
2010-04-14 15:36:42 +01:00
|
|
|
const char *devalias);
|
2010-03-02 09:40:51 +01:00
|
|
|
|
2010-01-26 15:34:46 +00:00
|
|
|
int qemuMonitorJSONAddDrive(qemuMonitorPtr mon,
|
|
|
|
const char *drivestr);
|
|
|
|
|
2010-12-08 14:30:12 -07:00
|
|
|
int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
|
2010-10-22 09:14:22 -05:00
|
|
|
const char *drivestr);
|
|
|
|
|
2010-02-11 14:28:16 +00:00
|
|
|
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
|
|
|
|
const char *alias,
|
|
|
|
const char *passphrase);
|
|
|
|
|
2010-04-02 10:10:37 -04:00
|
|
|
int qemuMonitorJSONCreateSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
int qemuMonitorJSONLoadSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
|
2011-08-15 17:25:54 -06:00
|
|
|
int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon,
|
2012-03-16 22:17:28 -06:00
|
|
|
virJSONValuePtr actions,
|
2011-08-15 17:25:54 -06:00
|
|
|
const char *device,
|
snapshot: improve qemu handling of reused snapshot targets
The oVirt developers have stated that the real reasons they want
to have qemu reuse existing volumes when creating a snapshot are:
1. the management framework is set up so that creation has to be
done from a central node for proper resource tracking, and having
libvirt and/or qemu create things violates the framework, and
2. qemu defaults to creating snapshots with an absolute path to
the backing file, but oVirt wants to manage a backing chain that
uses just relative names, to allow for easier migration of a chain
across storage locations.
When 0.9.10 added VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT (commit
4e9953a4), it only addressed point 1, but libvirt was still using
O_TRUNC which violates point 2. Meanwhile, the new qemu
'transaction' monitor command includes a new optional mode argument
that will force qemu to reuse the metadata of the file it just
opened (with the burden on the caller to have valid metadata there
in the first place). So, this tweaks the meaning of the flag to
cover both points as intended for use by oVirt. It is not strictly
backward-compatible to 0.9.10 behavior, but it can be argued that
the O_TRUNC of 0.9.10 was a bug.
Note that this flag is all-or-nothing, and only selects between
'existing' and the default 'absolute-paths'. A more flexible
approach that would allow per-disk selections, as well as adding
support for the 'no-backing-file' mode, would be possible by
extending the <domainsnapshot> xml to have a per-disk mode, but
until we have a management application expressing a need for that
additional complexity, it is not worth doing.
* src/libvirt.c (virDomainSnapshotCreateXML): Tweak documentation.
* src/qemu/qemu_monitor.h (qemuMonitorDiskSnapshot): Add
parameters.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorDiskSnapshot): Pass them
through.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot): Use
new monitor command arguments.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive)
(qemuDomainSnapshotCreateSingleDiskActive): Adjust callers.
(qemuDomainSnapshotDiskPrepare): Allow qed, modify rules on reuse.
2012-03-20 15:03:45 -06:00
|
|
|
const char *file,
|
|
|
|
const char *format,
|
|
|
|
bool reuse);
|
2012-03-16 22:17:28 -06:00
|
|
|
int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions);
|
2011-08-15 17:25:54 -06:00
|
|
|
|
2010-04-16 22:12:45 -04:00
|
|
|
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
|
|
|
|
const char *cmd_str,
|
2011-02-02 16:37:10 +01:00
|
|
|
char **reply_str,
|
|
|
|
bool hmp);
|
2010-04-16 22:12:45 -04:00
|
|
|
|
2011-05-10 16:26:06 +08:00
|
|
|
int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon);
|
2011-04-01 08:23:58 +02:00
|
|
|
|
2011-07-21 15:55:56 +08:00
|
|
|
int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
|
|
|
|
unsigned int holdtime,
|
|
|
|
unsigned int *keycodes,
|
|
|
|
unsigned int nkeycodes);
|
|
|
|
|
2011-04-01 08:23:58 +02:00
|
|
|
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
|
|
|
|
const char *file);
|
|
|
|
|
2011-07-22 13:39:37 +08:00
|
|
|
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
2012-02-18 09:20:01 -07:00
|
|
|
const char *base,
|
2011-07-22 13:39:37 +08:00
|
|
|
unsigned long bandwidth,
|
|
|
|
virDomainBlockJobInfoPtr info,
|
|
|
|
int mode);
|
2011-04-01 08:23:58 +02:00
|
|
|
|
2011-09-06 16:18:57 +08:00
|
|
|
int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
|
|
|
|
const char *name,
|
|
|
|
enum virDomainNetInterfaceLinkState state);
|
|
|
|
|
2011-10-21 09:00:13 +01:00
|
|
|
int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *fdname,
|
|
|
|
bool skipauth);
|
|
|
|
|
2011-11-15 17:02:45 +08:00
|
|
|
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
virDomainBlockIoTuneInfoPtr info);
|
|
|
|
|
|
|
|
int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
virDomainBlockIoTuneInfoPtr reply);
|
|
|
|
|
2012-02-10 13:33:52 +01:00
|
|
|
int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon);
|
|
|
|
|
2009-11-03 13:59:18 -05:00
|
|
|
#endif /* QEMU_MONITOR_JSON_H */
|