2009-09-22 17:48:40 +00:00
|
|
|
/*
|
|
|
|
* qemu_monitor_text.h: interaction with QEMU monitor console
|
|
|
|
*
|
2012-02-17 21:55:35 +00:00
|
|
|
* Copyright (C) 2006-2009, 2011-2012 Red Hat, Inc.
|
2009-09-22 17:48:40 +00: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
|
2012-07-21 10:06:23 +00:00
|
|
|
* License along with this library; If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-09-22 17:48:40 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef QEMU_MONITOR_TEXT_H
|
2010-03-09 18:22:22 +00:00
|
|
|
# define QEMU_MONITOR_TEXT_H
|
2009-09-22 17:48:40 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2009-09-22 17:48:40 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "qemu_monitor.h"
|
2009-10-09 20:13:06 +00:00
|
|
|
|
Fully asynchronous monitor I/O processing
Change the QEMU monitor file handle watch to poll for both
read & write events, as well as EOF. All I/O to/from the
QEMU monitor FD is now done in the event callback thread.
When the QEMU driver needs to send a command, it puts the
data to be sent into a qemuMonitorMessagePtr object instance,
queues it for dispatch, and then goes to sleep on a condition
variable. The event thread sends all the data, and then waits
for the reply to arrive, putting the response / error data
back into the qemuMonitorMessagePtr and notifying the condition
variable.
There is a temporary hack in the disk passphrase callback to
avoid acquiring the domain lock. This avoids a deadlock in
the command processing, since the domain lock is still held
when running monitor commands. The next commit will remove
the locking when running commands & thus allow re-introduction
of locking the disk passphrase callback
* src/qemu/qemu_driver.c: Temporarily don't acquire lock in
disk passphrase callback. To be reverted in next commit
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Remove
raw I/O functions, and a generic qemuMonitorSend() for
invoking a command
* src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
Remove all low level I/O, and use the new qemuMonitorSend()
API. Provide a qemuMonitorTextIOProcess() method for detecting
command/reply/prompt boundaries in the monitor data stream
2009-10-14 17:40:51 +00:00
|
|
|
int qemuMonitorTextIOProcess(qemuMonitorPtr mon,
|
|
|
|
const char *data,
|
|
|
|
size_t len,
|
|
|
|
qemuMonitorMessagePtr msg);
|
|
|
|
|
2011-03-09 20:24:04 +00:00
|
|
|
int qemuMonitorTextCommandWithFd(qemuMonitorPtr mon,
|
|
|
|
const char *cmd,
|
|
|
|
int scm_fd,
|
|
|
|
char **reply);
|
|
|
|
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextStartCPUs(qemuMonitorPtr mon,
|
|
|
|
virConnectPtr conn);
|
|
|
|
int qemuMonitorTextStopCPUs(qemuMonitorPtr mon);
|
2011-09-27 09:42:04 +00:00
|
|
|
int qemuMonitorTextGetStatus(qemuMonitorPtr mon,
|
|
|
|
bool *running,
|
|
|
|
virDomainPausedReason *reason);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextSystemPowerdown(qemuMonitorPtr mon);
|
2011-06-15 16:49:58 +00:00
|
|
|
int qemuMonitorTextSystemReset(qemuMonitorPtr mon);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
|
|
|
|
int **pids);
|
2011-06-17 14:31:45 +00:00
|
|
|
int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
|
|
|
|
int *virtType);
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
|
2012-03-02 20:27:39 +00:00
|
|
|
unsigned long long *currmem);
|
2009-12-20 12:36:28 +00:00
|
|
|
int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
|
|
|
|
virDomainMemoryStatPtr stats,
|
|
|
|
unsigned int nr_stats);
|
2011-09-13 13:49:50 +00:00
|
|
|
int qemuMonitorTextGetBlockInfo(qemuMonitorPtr mon,
|
2012-01-18 21:01:30 +00:00
|
|
|
virHashTablePtr table);
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
|
2011-09-16 12:05:58 +00:00
|
|
|
const char *dev_name,
|
2009-10-09 20:13:06 +00:00
|
|
|
long long *rd_req,
|
|
|
|
long long *rd_bytes,
|
2011-09-05 08:22:17 +00:00
|
|
|
long long *rd_total_times,
|
2009-10-09 20:13:06 +00:00
|
|
|
long long *wr_req,
|
|
|
|
long long *wr_bytes,
|
2011-09-05 08:22:17 +00:00
|
|
|
long long *wr_total_times,
|
|
|
|
long long *flush_req,
|
|
|
|
long long *flush_total_times,
|
2009-10-09 20:13:06 +00:00
|
|
|
long long *errs);
|
2011-09-05 08:22:17 +00:00
|
|
|
int qemuMonitorTextGetBlockStatsParamsNumber(qemuMonitorPtr mon,
|
|
|
|
int *nparams);
|
2010-05-14 13:10:01 +00:00
|
|
|
int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon,
|
2011-09-16 12:05:58 +00:00
|
|
|
const char *dev_name,
|
2010-05-14 13:10:01 +00:00
|
|
|
unsigned long long *extent);
|
2011-11-29 07:34:53 +00:00
|
|
|
int qemuMonitorTextBlockResize(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
unsigned long long size);
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextSetVNCPassword(qemuMonitorPtr mon,
|
|
|
|
const char *password);
|
2011-01-10 11:12:32 +00:00
|
|
|
int qemuMonitorTextSetPassword(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *password,
|
|
|
|
const char *action_if_connected);
|
|
|
|
int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *expire_time);
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
|
|
|
|
unsigned long newmem);
|
2010-02-08 16:37:17 +00:00
|
|
|
int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
|
2011-09-16 12:05:58 +00:00
|
|
|
const char *dev_name,
|
2010-11-08 17:52:48 +00:00
|
|
|
bool force);
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
|
2011-09-16 12:05:58 +00:00
|
|
|
const char *dev_name,
|
2009-11-26 13:48:17 +00:00
|
|
|
const char *newmedia,
|
|
|
|
const char *format);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
int qemuMonitorTextSaveVirtualMemory(qemuMonitorPtr mon,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t length,
|
|
|
|
const char *path);
|
|
|
|
int qemuMonitorTextSavePhysicalMemory(qemuMonitorPtr mon,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t length,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon,
|
|
|
|
unsigned long bandwidth);
|
|
|
|
|
2010-03-17 15:53:14 +00:00
|
|
|
int qemuMonitorTextSetMigrationDowntime(qemuMonitorPtr mon,
|
|
|
|
unsigned long long downtime);
|
|
|
|
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
|
|
|
int *status,
|
|
|
|
unsigned long long *transferred,
|
|
|
|
unsigned long long *remaining,
|
|
|
|
unsigned long long *total);
|
|
|
|
|
2011-03-04 18:51:48 +00:00
|
|
|
int qemuMonitorTextMigrate(qemuMonitorPtr mon,
|
|
|
|
unsigned int flags,
|
|
|
|
const char *uri);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon);
|
|
|
|
|
2011-02-17 13:39:36 +00:00
|
|
|
int qemuMonitorTextGraphicsRelocate(qemuMonitorPtr mon,
|
|
|
|
int type,
|
|
|
|
const char *hostname,
|
|
|
|
int port,
|
|
|
|
int tlsPort,
|
|
|
|
const char *tlsSubject);
|
|
|
|
|
2009-10-09 20:13:06 +00:00
|
|
|
int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
int qemuMonitorTextAddUSBDeviceExact(qemuMonitorPtr mon,
|
|
|
|
int bus,
|
|
|
|
int dev);
|
|
|
|
int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|
|
|
int vendor,
|
|
|
|
int product);
|
|
|
|
|
|
|
|
|
|
|
|
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *hostAddr,
|
|
|
|
virDevicePCIAddress *guestAddr);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
|
|
|
|
const char *path,
|
|
|
|
const char *bus,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *guestAddr);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
|
|
|
const char *nicstr,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *guestAddr);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *guestAddr);
|
2009-10-09 20:13:06 +00:00
|
|
|
|
|
|
|
int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
|
|
|
|
const char *fdname,
|
|
|
|
int fd);
|
|
|
|
|
|
|
|
int qemuMonitorTextCloseFileHandle(qemuMonitorPtr mon,
|
|
|
|
const char *fdname);
|
|
|
|
|
|
|
|
int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
|
|
|
|
const char *netstr);
|
|
|
|
|
|
|
|
int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon,
|
|
|
|
int vlan,
|
|
|
|
const char *netname);
|
2009-09-23 16:32:50 +00:00
|
|
|
|
2010-04-15 13:52:03 +00:00
|
|
|
int qemuMonitorTextAddNetdev(qemuMonitorPtr mon,
|
|
|
|
const char *netdevstr);
|
|
|
|
|
|
|
|
int qemuMonitorTextRemoveNetdev(qemuMonitorPtr mon,
|
|
|
|
const char *alias);
|
|
|
|
|
2009-12-14 09:50:01 +00:00
|
|
|
int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
|
|
|
|
virHashTablePtr paths);
|
|
|
|
|
2009-12-07 19:28:05 +00:00
|
|
|
int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon,
|
|
|
|
const char *bus,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *guestAddr);
|
2009-12-07 19:28:05 +00:00
|
|
|
|
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 qemuMonitorTextAttachDrive(qemuMonitorPtr mon,
|
|
|
|
const char *drivestr,
|
2012-08-16 15:41:06 +00:00
|
|
|
virDevicePCIAddress *controllerAddr,
|
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
|
|
|
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 qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon,
|
|
|
|
qemuMonitorPCIAddress **addrs);
|
2009-12-07 19:28:05 +00:00
|
|
|
|
2010-01-26 15:34:46 +00:00
|
|
|
int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
|
|
|
|
const char *devicestr);
|
|
|
|
|
2010-03-02 08:40:51 +00:00
|
|
|
int qemuMonitorTextDelDevice(qemuMonitorPtr mon,
|
2010-04-14 14:36:42 +00:00
|
|
|
const char *devalias);
|
2010-03-02 08:40:51 +00:00
|
|
|
|
2010-01-26 15:34:46 +00:00
|
|
|
int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
|
|
|
|
const char *drivestr);
|
|
|
|
|
2010-12-08 21:30:12 +00:00
|
|
|
int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
|
2010-10-22 14:14:22 +00:00
|
|
|
const char *drivestr);
|
|
|
|
|
2010-02-11 14:28:16 +00:00
|
|
|
int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
|
|
|
|
const char *alias,
|
|
|
|
const char *passphrase);
|
|
|
|
|
2010-04-02 14:10:37 +00:00
|
|
|
int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name);
|
|
|
|
|
2011-08-15 23:25:54 +00:00
|
|
|
int qemuMonitorTextDiskSnapshot(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
const char *file);
|
|
|
|
|
2010-04-17 02:12:45 +00:00
|
|
|
int qemuMonitorTextArbitraryCommand(qemuMonitorPtr mon, const char *cmd,
|
|
|
|
char **reply);
|
|
|
|
|
2011-05-10 08:26:06 +00:00
|
|
|
int qemuMonitorTextInjectNMI(qemuMonitorPtr mon);
|
2011-04-01 06:23:58 +00:00
|
|
|
|
2011-07-21 07:55:56 +00:00
|
|
|
int qemuMonitorTextSendKey(qemuMonitorPtr mon,
|
|
|
|
unsigned int holdtime,
|
|
|
|
unsigned int *keycodes,
|
|
|
|
unsigned int nkeycodes);
|
|
|
|
|
2011-04-01 06:23:58 +00:00
|
|
|
int qemuMonitorTextScreendump(qemuMonitorPtr mon, const char *file);
|
|
|
|
|
2011-09-06 08:18:57 +00:00
|
|
|
int qemuMonitorTextSetLink(qemuMonitorPtr mon,
|
|
|
|
const char *name,
|
|
|
|
enum virDomainNetInterfaceLinkState state);
|
|
|
|
|
2011-10-21 08:00:13 +00:00
|
|
|
int qemuMonitorTextOpenGraphics(qemuMonitorPtr mon,
|
|
|
|
const char *protocol,
|
|
|
|
const char *fdname,
|
|
|
|
bool skipauth);
|
|
|
|
|
2011-11-15 09:02:45 +00:00
|
|
|
int qemuMonitorTextSetBlockIoThrottle(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
virDomainBlockIoTuneInfoPtr info);
|
|
|
|
|
|
|
|
int qemuMonitorTextGetBlockIoThrottle(qemuMonitorPtr mon,
|
|
|
|
const char *device,
|
|
|
|
virDomainBlockIoTuneInfoPtr reply);
|
|
|
|
|
2009-09-23 10:49:14 +00:00
|
|
|
#endif /* QEMU_MONITOR_TEXT_H */
|