monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param
This patch renames+moves the net_handle_fd_param() caller used to obtain a file descriptor from either qemu_parse_fd() (the normal case) or from monitor_get_fd() (migration case) into a generically prefixed monitor_handle_fd_param() to be used by vhost-scsi code. Also update net/[socket,tap].c consumers to use the new prefix. Reported-by: Michael S. Tsirkin <mst@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
		
							parent
							
								
									0e180d9c8a
								
							
						
					
					
						commit
						a96ed02fc7
					
				
							
								
								
									
										18
									
								
								monitor.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								monitor.c
									
									
									
									
									
								
							@ -2651,6 +2651,24 @@ int monitor_fdset_dup_fd_remove(int dup_fd)
 | 
			
		||||
    return monitor_fdset_dup_fd_find_remove(dup_fd, true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int monitor_handle_fd_param(Monitor *mon, const char *fdname)
 | 
			
		||||
{
 | 
			
		||||
    int fd;
 | 
			
		||||
 | 
			
		||||
    if (!qemu_isdigit(fdname[0]) && mon) {
 | 
			
		||||
 | 
			
		||||
        fd = monitor_get_fd(mon, fdname);
 | 
			
		||||
        if (fd == -1) {
 | 
			
		||||
            error_report("No file descriptor named %s found", fdname);
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        fd = qemu_parse_fd(fdname);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* mon_cmds and info_cmds would be sorted at runtime */
 | 
			
		||||
static mon_cmd_t mon_cmds[] = {
 | 
			
		||||
#include "hmp-commands.h"
 | 
			
		||||
 | 
			
		||||
@ -66,6 +66,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
 | 
			
		||||
                                  void *opaque);
 | 
			
		||||
 | 
			
		||||
int monitor_get_fd(Monitor *mon, const char *fdname);
 | 
			
		||||
int monitor_handle_fd_param(Monitor *mon, const char *fdname);
 | 
			
		||||
 | 
			
		||||
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
 | 
			
		||||
    GCC_FMT_ATTR(2, 0);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								net.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								net.c
									
									
									
									
									
								
							@ -522,24 +522,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int net_handle_fd_param(Monitor *mon, const char *param)
 | 
			
		||||
{
 | 
			
		||||
    int fd;
 | 
			
		||||
 | 
			
		||||
    if (!qemu_isdigit(param[0]) && mon) {
 | 
			
		||||
 | 
			
		||||
        fd = monitor_get_fd(mon, param);
 | 
			
		||||
        if (fd == -1) {
 | 
			
		||||
            error_report("No file descriptor named %s found", param);
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        fd = qemu_parse_fd(param);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int net_init_nic(const NetClientOptions *opts, const char *name,
 | 
			
		||||
                        NetClientState *peer)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								net.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								net.h
									
									
									
									
									
								
							@ -168,8 +168,6 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret);
 | 
			
		||||
 | 
			
		||||
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
 | 
			
		||||
 | 
			
		||||
int net_handle_fd_param(Monitor *mon, const char *param);
 | 
			
		||||
 | 
			
		||||
#define POLYNOMIAL 0x04c11db6
 | 
			
		||||
unsigned compute_mcast_idx(const uint8_t *ep);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -629,7 +629,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name,
 | 
			
		||||
    if (sock->has_fd) {
 | 
			
		||||
        int fd;
 | 
			
		||||
 | 
			
		||||
        fd = net_handle_fd_param(cur_mon, sock->fd);
 | 
			
		||||
        fd = monitor_handle_fd_param(cur_mon, sock->fd);
 | 
			
		||||
        if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) {
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -610,7 +610,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fd = net_handle_fd_param(cur_mon, tap->fd);
 | 
			
		||||
        fd = monitor_handle_fd_param(cur_mon, tap->fd);
 | 
			
		||||
        if (fd == -1) {
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
@ -686,7 +686,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
 | 
			
		||||
        int vhostfd;
 | 
			
		||||
 | 
			
		||||
        if (tap->has_vhostfd) {
 | 
			
		||||
            vhostfd = net_handle_fd_param(cur_mon, tap->vhostfd);
 | 
			
		||||
            vhostfd = monitor_handle_fd_param(cur_mon, tap->vhostfd);
 | 
			
		||||
            if (vhostfd == -1) {
 | 
			
		||||
                return -1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user