dm: remove the assume of virtio-net device name

Now, the DM assumes the device name entered by user is dependent on
the type.

For example, the device of tap type is named tap_TAAG, this patch
remove the above assumption.

User could set any name, no matter the code of DM or actually created,
it is represented by user input.

Tracked-On: #6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Chenli Wei<chenli.wei@linux.intel.com>
This commit is contained in:
Chenli Wei 2022-02-14 22:53:11 +08:00 committed by acrnsi-robot
parent 04eefc9516
commit b9431b8da4

View File

@ -820,7 +820,6 @@ virtio_net_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
char nstr[80]; char nstr[80];
char tname[MAXCOMLEN + 1]; char tname[MAXCOMLEN + 1];
struct virtio_net *net; struct virtio_net *net;
char fname[IFNAMSIZ];
char *devopts = NULL; char *devopts = NULL;
char *name = NULL; char *name = NULL;
char *type = NULL; char *type = NULL;
@ -911,23 +910,20 @@ virtio_net_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
} }
vtopts = tmp = strdup(opts); vtopts = tmp = strdup(opts);
if ((strstr(tmp, "tap") != NULL) if (strncmp(tmp, "tap", 3) == 0) {
|| (strncmp(tmp, "vmnet",5) == 0)) {
type = strsep(&tmp, "="); type = strsep(&tmp, "=");
name = strsep(&tmp, ","); name = strsep(&tmp, ",");
} }
if ((tmp != NULL) && (strncmp(tmp, "mac_seed",8) == 0)) { if ((tmp != NULL) && (strncmp(tmp, "mac_seed", 8) == 0)) {
strsep(&tmp, "="); strsep(&tmp, "=");
mac_seed = tmp; mac_seed = tmp;
} }
if ((type != NULL) && (name != NULL)) { if ((type != NULL) && (name != NULL)) {
snprintf(fname, IFNAMSIZ, "%s_%s", type, name);
if ((strstr(type, "tap") != NULL) || if (strcmp(type, "tap") == 0) {
(strncmp(type, "vmnet", 5) == 0)){ virtio_net_tap_setup(net, name);
virtio_net_tap_setup(net, fname);
} }
} }