Similar to commit
57d084febe, another case of the libxl driver not
adapting to modular daemons. When converting configuration that
contains a type='network' interface, the converter calls
virNetworkLookupByName, passing the hypervisor connection object
instead of a connection to virtnetworkd. E.g.
> cat dom.xml
...
<interface type='network'>
<source network='default'/>
</interface>
...
> virsh net-info default
Name: default
UUID:
25a5b089-1e71-4956-99aa-
df2213bbb407
Active: yes
Persistent: no
Autostart: no
Bridge: virbr0
> virsh domxml-to-native xen-xl dom.xml
error: Network not found: default
Acquire a connection to virtnetworkd and use it when calling
virNetwork* APIs.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
goto cleanup;
if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XL)) {
- if (!(conf = xenFormatXL(def, conn)))
+ if (!(conf = xenFormatXL(def)))
goto cleanup;
} else if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
- if (!(conf = xenFormatXM(conn, def)))
+ if (!(conf = xenFormatXM(def)))
goto cleanup;
} else {
#include <config.h>
+#include "datatypes.h"
+#include "driver.h"
#include "internal.h"
#include "virerror.h"
#include "virconf.h"
}
static int
-xenFormatNet(virConnectPtr conn,
- virConfValue *list,
+xenFormatNet(virConfValue *list,
virDomainNetDef *net,
int hvm,
const char *vif_typename)
case VIR_DOMAIN_NET_TYPE_NETWORK:
{
- virNetworkPtr network = virNetworkLookupByName(conn, net->data.network.name);
+ g_autoptr(virConnect) conn = NULL;
+ virNetworkPtr network;
char *bridge;
- if (!network) {
+
+ if (!(conn = virGetConnectNetwork()))
+ return -1;
+
+ if (!(network = virNetworkLookupByName(conn, net->data.network.name))) {
virReportError(VIR_ERR_NO_NETWORK, "%s",
net->data.network.name);
return -1;
}
+
bridge = virNetworkGetBridgeName(network);
virObjectUnref(network);
if (!bridge) {
static int
xenFormatVif(virConf *conf,
- virConnectPtr conn,
virDomainDef *def,
const char *vif_typename)
{
netVal->list = NULL;
for (i = 0; i < def->nnets; i++) {
- if (xenFormatNet(conn, netVal, def->nets[i],
- hvm, vif_typename) < 0)
+ if (xenFormatNet(netVal, def->nets[i], hvm, vif_typename) < 0)
return -1;
}
int
xenFormatConfigCommon(virConf *conf,
virDomainDef *def,
- virConnectPtr conn,
const char *nativeFormat)
{
if (xenFormatGeneralMeta(conf, def) < 0)
return -1;
if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XL)) {
- if (xenFormatVif(conf, conn, def, "vif") < 0)
+ if (xenFormatVif(conf, def, "vif") < 0)
return -1;
} else if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
- if (xenFormatVif(conf, conn, def, "netfront") < 0)
+ if (xenFormatVif(conf, def, "netfront") < 0)
return -1;
} else {
virReportError(VIR_ERR_INVALID_ARG,
int xenFormatConfigCommon(virConf *conf,
virDomainDef *def,
- virConnectPtr conn,
const char *nativeFormat);
char *xenMakeIPList(virNetDevIPInfo *guestIP);
}
virConf *
-xenFormatXL(virDomainDef *def, virConnectPtr conn)
+xenFormatXL(virDomainDef *def)
{
g_autoptr(virConf) conf = NULL;
if (!(conf = virConfNew()))
return NULL;
- if (xenFormatConfigCommon(conf, def, conn, XEN_CONFIG_FORMAT_XL) < 0)
+ if (xenFormatConfigCommon(conf, def, XEN_CONFIG_FORMAT_XL) < 0)
return NULL;
if (xenFormatXLOS(conf, def) < 0)
virCaps *caps,
virDomainXMLOption *xmlopt);
-virConf *xenFormatXL(virDomainDef *def, virConnectPtr);
+virConf *xenFormatXL(virDomainDef *def);
const char *xenTranslateCPUFeature(const char *feature_name, bool from_libxl);
* Convert a virDomainDef object into an XM config record.
*/
virConf *
-xenFormatXM(virConnectPtr conn,
- virDomainDef *def)
+xenFormatXM(virDomainDef *def)
{
g_autoptr(virConf) conf = NULL;
if (!(conf = virConfNew()))
return NULL;
- if (xenFormatConfigCommon(conf, def, conn, XEN_CONFIG_FORMAT_XM) < 0)
+ if (xenFormatConfigCommon(conf, def, XEN_CONFIG_FORMAT_XM) < 0)
return NULL;
if (xenFormatXMOS(conf, def) < 0)
#include "virconf.h"
#include "domain_conf.h"
-virConf *xenFormatXM(virConnectPtr conn, virDomainDef *def);
+virConf *xenFormatXM(virDomainDef *def);
virDomainDef *xenParseXM(virConf *conf,
virCaps *caps, virDomainXMLOption *xmlopt);
{
g_autofree char *gotxlcfgData = NULL;
g_autoptr(virConf) conf = NULL;
- g_autoptr(virConnect) conn = NULL;
int wrote = 4096;
g_autoptr(virDomainDef) def = NULL;
g_autofree char *replacedXML = NULL;
gotxlcfgData = g_new0(char, wrote);
- conn = virGetConnect();
- if (!conn)
- return -1;
-
if (replaceVars) {
if (!(replacedXML = testReplaceVarsXML(xml)))
return -1;
return -1;
}
- if (!(conf = xenFormatXL(def, conn)))
+ if (!(conf = xenFormatXL(def)))
return -1;
if (virConfWriteMem(gotxlcfgData, &wrote, conf) < 0)
{
g_autofree char *gotxmcfgData = NULL;
g_autoptr(virConf) conf = NULL;
- g_autoptr(virConnect) conn = NULL;
int wrote = 4096;
g_autoptr(virDomainDef) def = NULL;
gotxmcfgData = g_new0(char, wrote);
- conn = virGetConnect();
- if (!conn)
- return -1;
-
if (!(def = virDomainDefParseFile(xml, driver->xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
return -1;
return -1;
}
- if (!(conf = xenFormatXM(conn, def)))
+ if (!(conf = xenFormatXM(def)))
return -1;
if (virConfWriteMem(gotxmcfgData, &wrote, conf) < 0)