Move vnet_hdr logic into qemudNetworkIfaceConnect() and export it

* src/qemu_conf.h: export qemudNetworkIfaceConnect()

* src/qemu_conf.c: move vnet_hdr logic into qemudNetworkIfaceConnect()
  since we need it for hotplug too
This commit is contained in:
Mark McLoughlin 2009-07-22 20:17:13 +01:00
parent 707302b2cf
commit a3f33b6531
2 changed files with 13 additions and 9 deletions

View File

@ -1014,15 +1014,16 @@ int qemudExtractVersion(virConnectPtr conn,
}
static int
int
qemudNetworkIfaceConnect(virConnectPtr conn,
struct qemud_driver *driver,
virDomainNetDefPtr net,
int vnet_hdr)
int qemuCmdFlags)
{
char *brname;
int err;
int tapfd = -1;
int vnet_hdr = 0;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
virNetworkPtr network = virNetworkLookupByName(conn,
@ -1062,6 +1063,10 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
return -1;
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR &&
net->model && STREQ(net->model, "virtio"))
vnet_hdr = 1;
if ((err = brAddTap(driver->brctl, brname,
&net->ifname, vnet_hdr, &tapfd))) {
if (errno == ENOTSUP) {
@ -1816,13 +1821,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
int vnet_hdr = 0;
if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR &&
net->model && STREQ(net->model, "virtio"))
vnet_hdr = 1;
tapfd = qemudNetworkIfaceConnect(conn, driver, net, vnet_hdr);
tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
if (tapfd < 0)
goto error;

View File

@ -165,6 +165,11 @@ int qemuBuildNicStr (virConnectPtr conn,
int vlan,
char **str);
int qemudNetworkIfaceConnect (virConnectPtr conn,
struct qemud_driver *driver,
virDomainNetDefPtr net,
int qemuCmdFlags);
int qemuAssignNetNames (virDomainDefPtr def,
virDomainNetDefPtr net);