mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
qemu: monitor: Add APIs for cdrom tray handling for -blockdev
With blockdev we can use the full range of commands to manipulate the tray and the medium separately. Implement monitor code for this. Schema testing done in the qemumonitorjsontest allows us to verify that we generate the commands correctly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6d5468adc4
commit
2771b37209
@ -4336,6 +4336,56 @@ qemuMonitorBlockdevDel(qemuMonitorPtr mon,
|
||||
return qemuMonitorJSONBlockdevDel(mon, nodename);
|
||||
}
|
||||
|
||||
int
|
||||
qemuMonitorBlockdevTrayOpen(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
bool force)
|
||||
{
|
||||
VIR_DEBUG("id=%s force=%d", id, force);
|
||||
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONBlockdevTrayOpen(mon, id, force);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorBlockdevTrayClose(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
{
|
||||
VIR_DEBUG("id=%s", id);
|
||||
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONBlockdevTrayClose(mon, id);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorBlockdevMediumRemove(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
{
|
||||
VIR_DEBUG("id=%s", id);
|
||||
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONBlockdevMediumRemove(mon, id);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorBlockdevMediumInsert(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
const char *nodename)
|
||||
{
|
||||
VIR_DEBUG("id=%s nodename=%s", id, nodename);
|
||||
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONBlockdevMediumInsert(mon, id, nodename);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon)
|
||||
{
|
||||
|
@ -1155,6 +1155,20 @@ int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
|
||||
int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
|
||||
const char *nodename);
|
||||
|
||||
int qemuMonitorBlockdevTrayOpen(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
bool force);
|
||||
|
||||
int qemuMonitorBlockdevTrayClose(qemuMonitorPtr mon,
|
||||
const char *id);
|
||||
|
||||
int qemuMonitorBlockdevMediumRemove(qemuMonitorPtr mon,
|
||||
const char *id);
|
||||
|
||||
int qemuMonitorBlockdevMediumInsert(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
const char *nodename);
|
||||
|
||||
char *
|
||||
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon);
|
||||
|
||||
|
@ -8025,6 +8025,120 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockdevTrayOpen(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
bool force)
|
||||
{
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-open-tray",
|
||||
"s:id", id,
|
||||
"b:force", force, NULL)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockdevTrayClose(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
{
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-close-tray",
|
||||
"s:id", id, NULL)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockdevMediumRemove(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
{
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-remove-medium",
|
||||
"s:id", id, NULL)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockdevMediumInsert(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
const char *nodename)
|
||||
{
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-insert-medium",
|
||||
"s:id", id,
|
||||
"s:node-name", nodename,
|
||||
NULL)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The function is used to retrieve the measurement of a SEV guest.
|
||||
* The measurement is signature of the memory contents that was encrypted
|
||||
|
@ -549,6 +549,24 @@ int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
|
||||
const char *nodename)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorJSONBlockdevTrayOpen(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
bool force)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorJSONBlockdevTrayClose(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorJSONBlockdevMediumRemove(qemuMonitorPtr mon,
|
||||
const char *id)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorJSONBlockdevMediumInsert(qemuMonitorPtr mon,
|
||||
const char *id,
|
||||
const char *nodename)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||
|
||||
int qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon,
|
||||
virHashTablePtr info)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
@ -1352,6 +1352,10 @@ GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false)
|
||||
GEN_TEST_FUNC(qemuMonitorJSONNBDServerStart, "localhost", 12345, "test-alias")
|
||||
GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", true)
|
||||
GEN_TEST_FUNC(qemuMonitorJSONDetachCharDev, "serial1")
|
||||
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayOpen, "foodev", true)
|
||||
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayClose, "foodev")
|
||||
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumRemove, "foodev")
|
||||
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "foodev", "newnode")
|
||||
|
||||
static bool
|
||||
testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCpusEntry *a,
|
||||
@ -2992,6 +2996,10 @@ mymain(void)
|
||||
DO_TEST_GEN(qemuMonitorJSONNBDServerStart);
|
||||
DO_TEST_GEN(qemuMonitorJSONNBDServerAdd);
|
||||
DO_TEST_GEN(qemuMonitorJSONDetachCharDev);
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockdevTrayOpen);
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockdevTrayClose);
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockdevMediumRemove);
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockdevMediumInsert);
|
||||
DO_TEST(qemuMonitorJSONGetBalloonInfo);
|
||||
DO_TEST(qemuMonitorJSONGetBlockInfo);
|
||||
DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user