Commit af1a5c3e authored by Thomas Huth's avatar Thomas Huth Committed by Jason Wang
Browse files

net: Remove the deprecated "vlan" parameter

It's been marked as deprecated since QEMU v2.9.0, so that should have
been enough time for everybody to either just drop unnecessary "vlan=0"
parameters, to switch to the modern -device + -netdev syntax for connecting
guest NICs with host network backends, or to switch to the "hubport" netdev
in case hubs are really wanted instead.

Buglink: https://bugs.launchpad.net/qemu/+bug/658904


Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
parent 9d946191
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -277,9 +277,6 @@ devices and ne2k_isa are.

Some PCI devices aren't available with -net nic, e.g. i82558a.

To connect to a VLAN instead of an ordinary host part, replace
netdev=NET-ID by vlan=VLAN.

=== Graphics Devices ===

Host and guest part of graphics devices have always been separate.
+0 −80
Original line number Diff line number Diff line
@@ -321,86 +321,6 @@ const PropertyInfo qdev_prop_netdev = {
    .set   = set_netdev,
};

/* --- vlan --- */

static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
{
    NetClientState **ptr = qdev_get_prop_ptr(dev, prop);

    if (*ptr) {
        int id;
        if (!net_hub_id_for_client(*ptr, &id)) {
            return snprintf(dest, len, "%d", id);
        }
    }

    return snprintf(dest, len, "<null>");
}

static void get_vlan(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
{
    DeviceState *dev = DEVICE(obj);
    Property *prop = opaque;
    NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
    int32_t id = -1;

    if (*ptr) {
        int hub_id;
        if (!net_hub_id_for_client(*ptr, &hub_id)) {
            id = hub_id;
        }
    }

    visit_type_int32(v, name, &id, errp);
}

static void set_vlan(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
{
    DeviceState *dev = DEVICE(obj);
    Property *prop = opaque;
    NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
    NetClientState **ptr = &peers_ptr->ncs[0];
    Error *local_err = NULL;
    int32_t id;
    NetClientState *hubport;

    if (dev->realized) {
        qdev_prop_set_after_realize(dev, name, errp);
        return;
    }

    visit_type_int32(v, name, &id, &local_err);
    if (local_err) {
        error_propagate(errp, local_err);
        return;
    }
    if (id == -1) {
        *ptr = NULL;
        return;
    }
    if (*ptr) {
        error_set_from_qdev_prop_error(errp, -EINVAL, dev, prop, name);
        return;
    }

    hubport = net_hub_port_find(id);
    if (!hubport) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                   name, prop->info->name);
        return;
    }
    *ptr = hubport;
}

const PropertyInfo qdev_prop_vlan = {
    .name  = "int32",
    .description = "Integer VLAN id to connect to",
    .print = print_vlan,
    .get   = get_vlan,
    .set   = set_vlan,
};

void qdev_prop_set_drive(DeviceState *dev, const char *name,
                         BlockBackend *value, Error **errp)
+0 −3
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ extern const PropertyInfo qdev_prop_bios_chs_trans;
extern const PropertyInfo qdev_prop_fdc_drive_type;
extern const PropertyInfo qdev_prop_drive;
extern const PropertyInfo qdev_prop_netdev;
extern const PropertyInfo qdev_prop_vlan;
extern const PropertyInfo qdev_prop_pci_devfn;
extern const PropertyInfo qdev_prop_blocksize;
extern const PropertyInfo qdev_prop_pci_host_devaddr;
@@ -195,8 +194,6 @@ extern const PropertyInfo qdev_prop_off_auto_pcibar;
    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers)
#define DEFINE_PROP_VLAN(_n, _s, _f)             \
    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NICPeers)
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockBackend *)
#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ typedef struct NICConf {

#define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
    DEFINE_PROP_VLAN("vlan",     _state, _conf.peers),                   \
    DEFINE_PROP_NETDEV("netdev", _state, _conf.peers)


+3 −9
Original line number Diff line number Diff line
@@ -965,7 +965,6 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
    const Netdev *netdev;
    const char *name;
    NetClientState *peer = NULL;
    static bool vlan_warned;

    if (is_netdev) {
        netdev = object;
@@ -1036,15 +1035,10 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
            return -1;
        }

        /* Do not add to a vlan if it's a nic with a netdev= parameter. */
        /* Do not add to a hub if it's a nic with a netdev= parameter. */
        if (netdev->type != NET_CLIENT_DRIVER_NIC ||
            !opts->u.nic.has_netdev) {
            peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL, NULL);
        }

        if (net->has_vlan && !vlan_warned) {
            error_report("'vlan' is deprecated. Please use 'netdev' instead.");
            vlan_warned = true;
            peer = net_hub_add_port(0, NULL, NULL);
        }
    }

@@ -1365,7 +1359,7 @@ void qmp_set_link(const char *name, bool up, Error **errp)
         * If the peer is a HUBPORT or a backend, we do not change the
         * link status.
         *
         * This behavior is compatible with qemu vlans where there could be
         * This behavior is compatible with qemu hubs where there could be
         * multiple clients that can still communicate with each other in
         * disconnected mode. For now maintain this compatibility.
         */
Loading