net: slirp: switch to slirp_new

Replace slirp_init with slirp_new, so that a more recent cfg.version
can be specified.  The function appeared in version 4.1.0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2022-04-11 10:16:36 +02:00
parent ad2e5b87d7
commit bce63ded20
2 changed files with 22 additions and 7 deletions

View File

@ -2638,7 +2638,7 @@ if have_system
if slirp_opt in ['enabled', 'auto', 'system']
have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
slirp = dependency('slirp', kwargs: static_kwargs,
method: 'pkg-config',
method: 'pkg-config', version: '>=4.1.0',
required: slirp_opt == 'system' or
slirp_opt == 'enabled' and not have_internal)
if slirp.found()

View File

@ -389,6 +389,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
#if defined(CONFIG_SMBD_COMMAND)
struct in_addr smbsrv = { .s_addr = 0 };
#endif
SlirpConfig cfg = { 0 };
NetClientState *nc;
SlirpState *s;
char buf[20];
@ -577,12 +578,26 @@ static int net_slirp_init(NetClientState *peer, const char *model,
s = DO_UPCAST(SlirpState, nc, nc);
s->slirp = slirp_init(restricted, ipv4, net, mask, host,
ipv6, ip6_prefix, vprefix6_len, ip6_host,
vhostname, tftp_server_name,
tftp_export, bootfile, dhcp,
dns, ip6_dns, dnssearch, vdomainname,
&slirp_cb, s);
cfg.version = 1;
cfg.restricted = restricted;
cfg.in_enabled = ipv4;
cfg.vnetwork = net;
cfg.vnetmask = mask;
cfg.vhost = host;
cfg.in6_enabled = ipv6;
cfg.vprefix_addr6 = ip6_prefix;
cfg.vprefix_len = vprefix6_len;
cfg.vhost6 = ip6_host;
cfg.vhostname = vhostname;
cfg.tftp_server_name = tftp_server_name;
cfg.tftp_path = tftp_export;
cfg.bootfile = bootfile;
cfg.vdhcp_start = dhcp;
cfg.vnameserver = dns;
cfg.vnameserver6 = ip6_dns;
cfg.vdnssearch = dnssearch;
cfg.vdomainname = vdomainname;
s->slirp = slirp_new(&cfg, &slirp_cb, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
/*