@@ -1606,7 +1606,7 @@ ERST
.name = "closefd",
.args_type = "fdname:s",
.params = "closefd name",
- .help = "close a file descriptor previously passed via SCM rights",
+ .help = "close a named file descriptor",
.cmd = hmp_closefd,
},
@@ -1617,6 +1617,20 @@ SRST
used by another monitor command.
ERST
+ {
+ .name = "openfd",
+ .args_type = "fdname:s,filename:s",
+ .params = "openfd name filename",
+ .help = "open the named file (read write) and assign it a name",
+ .cmd = hmp_openfd,
+ },
+
+SRST
+``openfd`` *fdname* *filename*
+ Open the named file and store it using the name *fdname* for later use by
+ other monitor comands.
+ERST
+
{
.name = "block_passwd",
.args_type = "device:B,password:s",
@@ -83,6 +83,7 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
void hmp_netdev_del(Monitor *mon, const QDict *qdict);
void hmp_getfd(Monitor *mon, const QDict *qdict);
void hmp_closefd(Monitor *mon, const QDict *qdict);
+void hmp_openfd(Monitor *mon, const QDict *qdict);
void hmp_sendkey(Monitor *mon, const QDict *qdict);
void hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
@@ -1659,6 +1659,16 @@ void hmp_closefd(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
+void hmp_openfd(Monitor *mon, const QDict *qdict)
+{
+ const char *fdname = qdict_get_str(qdict, "fdname");
+ const char *filename = qdict_get_str(qdict, "filename");
+ Error *err = NULL;
+
+ qmp_openfd(fdname, filename, &err);
+ hmp_handle_error(mon, err);
+}
+
void hmp_sendkey(Monitor *mon, const QDict *qdict)
{
const char *keys = qdict_get_str(qdict, "keys");
@@ -57,6 +57,8 @@ static const char *hmp_cmds[] = {
"o /w 0 0x1234",
"object_add memory-backend-ram,id=mem1,size=256M",
"object_del mem1",
+ "openfd null \"/dev/null\"",
+ "closefd null", /* purposely after openfd */
"pmemsave 0 4096 \"/dev/null\"",
"p $pc + 8",
"qom-list /",