The function calls the respective CH API to remove a device of any type from a VM.
On-behalf-of: SAP stefan.ko...@sap.com Signed-off-by: Stefan Kober <stefan.ko...@cyberus-technology.de> --- src/ch/ch_monitor.c | 17 +++++++++++++++++ src/ch/ch_monitor.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 8968d84a71..2e21823f08 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -596,6 +596,23 @@ virCHMonitorBuildKeyValueStringJson(char **jsonstr, return 0; } +int virCHMonitorRemoveDevice(virCHMonitor *mon, + const char* device_id) +{ + g_autofree char *payload = NULL; + + if (virCHMonitorBuildKeyValueStringJson(&payload, "id", device_id) != 0) + return -1; + + VIR_DEBUG("Remove device %s", device_id); + + if (virCHMonitorPut(mon, URL_VM_REMOVE_DEVICE, payload, NULL) == NULL) { + return -1; + } + + return 0; +} + static int chMonitorCreateSocket(const char *socket_path) { diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index 8338059c7c..e8fa393e54 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -41,6 +41,7 @@ #define URL_VM_SAVE "vm.snapshot" #define URL_VM_RESTORE "vm.restore" #define URL_VM_ADD_DISK "vm.add-disk" +#define URL_VM_REMOVE_DEVICE "vm.remove-device" #define VIRCH_THREAD_NAME_LEN 16 @@ -141,6 +142,8 @@ virCHMonitorBuildNetJson(virDomainNetDef *netdef, char **jsonstr); int virCHMonitorAddDisk(virCHMonitor* mon, virDomainDiskDef *diskdef); +int virCHMonitorRemoveDevice(virCHMonitor *mon, + const char* device_id); int virCHMonitorBuildRestoreJson(virDomainDef *vmdef, const char *from, -- 2.50.1