@@ -2496,6 +2496,23 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
return -1;
}
+int monitor_handle_fd_param(Monitor *mon, const char *param)
+{
+ if (!qemu_isdigit(param[0])) {
+ int fd;
+
+ fd = monitor_get_fd(mon, param);
+ if (fd == -1) {
+ error_report("No file descriptor named %s found", param);
+ return -1;
+ }
+
+ return fd;
+ } else {
+ return strtol(param, NULL, 0);
+ }
+}
+
static const mon_cmd_t mon_cmds[] = {
#include "qemu-monitor.h"
{ NULL, NULL, },
@@ -44,6 +44,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
void *opaque);
int monitor_get_fd(Monitor *mon, const char *fdname);
+int monitor_handle_fd_param(Monitor *mon, const char *param);
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap);
void monitor_printf(Monitor *mon, const char *fmt, ...)
@@ -737,23 +737,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
return -1;
}
-int net_handle_fd_param(Monitor *mon, const char *param)
-{
- if (!qemu_isdigit(param[0])) {
- int fd;
-
- fd = monitor_get_fd(mon, param);
- if (fd == -1) {
- error_report("No file descriptor named %s found", param);
- return -1;
- }
-
- return fd;
- } else {
- return strtol(param, NULL, 0);
- }
-}
-
static int net_init_nic(QemuOpts *opts,
Monitor *mon,
const char *name,
@@ -177,6 +177,4 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
-int net_handle_fd_param(Monitor *mon, const char *param);
-
#endif
@@ -31,6 +31,7 @@
#include "qemu-error.h"
#include "qemu-option.h"
#include "qemu_socket.h"
+#include "monitor.h"
typedef struct NetSocketState {
VLANClientState nc;
@@ -510,7 +511,7 @@ int net_init_socket(QemuOpts *opts,
return -1;
}
- fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
+ fd = monitor_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
@@ -39,6 +39,7 @@
#include "qemu-char.h"
#include "qemu-common.h"
#include "qemu-error.h"
+#include "monitor.h"
#include "net/tap-linux.h"
@@ -413,7 +414,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
return -1;
}
- fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
+ fd = monitor_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
@@ -468,7 +469,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) {
int vhostfd, r;
if (qemu_opt_get(opts, "vhostfd")) {
- r = net_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
+ r = monitor_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
if (r == -1) {
return -1;
}
Move to monitor.c:monitor_handle_fd_param() as a common helper. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> --- I'd like to use this for the proposed device assignment configfd parameter since there's nothing net specific about it. monitor.c | 17 +++++++++++++++++ monitor.h | 1 + net.c | 17 ----------------- net.h | 2 -- net/socket.c | 3 ++- net/tap.c | 5 +++-- 6 files changed, 23 insertions(+), 22 deletions(-)