mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 17:24:53 +00:00
qemu_monitor: Introduce qemuMonitorDetachCharDev
This function wraps 'chardev-remove' qemu monitor command around. It takes chardev alias as its single argument besides qemu monitor pointer.
This commit is contained in:
parent
4a51447abe
commit
0f7a7ce5ff
@ -3643,3 +3643,23 @@ int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
return qemuMonitorJSONAttachCharDev(mon, chrID, chr);
|
return qemuMonitorJSONAttachCharDev(mon, chrID, chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
|
||||||
|
const char *chrID)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("mon=%p chrID=%s", mon, chrID);
|
||||||
|
|
||||||
|
if (!mon) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("monitor must not be NULL"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mon->json) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
|
_("JSON monitor is required"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemuMonitorJSONDetachCharDev(mon, chrID);
|
||||||
|
}
|
||||||
|
@ -704,6 +704,8 @@ int qemuMonitorGetTPMTypes(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
|
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
|
||||||
const char *chrID,
|
const char *chrID,
|
||||||
virDomainChrSourceDefPtr chr);
|
virDomainChrSourceDefPtr chr);
|
||||||
|
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
|
||||||
|
const char *chrID);
|
||||||
/**
|
/**
|
||||||
* When running two dd process and using <> redirection, we need a
|
* When running two dd process and using <> redirection, we need a
|
||||||
* shell that will not truncate files. These two strings serve that
|
* shell that will not truncate files. These two strings serve that
|
||||||
|
@ -5123,3 +5123,26 @@ cleanup:
|
|||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
|
||||||
|
const char *chrID)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
virJSONValuePtr cmd;
|
||||||
|
virJSONValuePtr reply = NULL;
|
||||||
|
|
||||||
|
if (!(cmd = qemuMonitorJSONMakeCommand("chardev-remove",
|
||||||
|
"s:id", chrID,
|
||||||
|
NULL)))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
|
|
||||||
|
virJSONValueFree(cmd);
|
||||||
|
virJSONValueFree(reply);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -356,4 +356,6 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
|
int qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
|
||||||
const char *chrID,
|
const char *chrID,
|
||||||
virDomainChrSourceDefPtr chr);
|
virDomainChrSourceDefPtr chr);
|
||||||
|
int qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
|
||||||
|
const char *chrID);
|
||||||
#endif /* QEMU_MONITOR_JSON_H */
|
#endif /* QEMU_MONITOR_JSON_H */
|
||||||
|
@ -675,6 +675,30 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testQemuMonitorJSONDetachChardev(const void *data)
|
||||||
|
{
|
||||||
|
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||||
|
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt);
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!test)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (qemuMonitorTestAddItem(test, "chardev-remove", "{\"return\": {}}") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuMonitorDetachCharDev(qemuMonitorTestGetMonitor(test),
|
||||||
|
"dummy_chrID") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
qemuMonitorTestFree(test);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
@ -704,6 +728,7 @@ mymain(void)
|
|||||||
DO_TEST(GetTPMModels);
|
DO_TEST(GetTPMModels);
|
||||||
DO_TEST(GetCommandLineOptionParameters);
|
DO_TEST(GetCommandLineOptionParameters);
|
||||||
DO_TEST(AttachChardev);
|
DO_TEST(AttachChardev);
|
||||||
|
DO_TEST(DetachChardev);
|
||||||
|
|
||||||
virObjectUnref(xmlopt);
|
virObjectUnref(xmlopt);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user