mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
Re-work test driver to implement (nearly) all APIs
This commit is contained in:
parent
1d7164058c
commit
4e01a607e4
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Fri Jul 27 19:19:31 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* src/test.c: Added impl of networking APIs. Cleanup all other
|
||||||
|
existing APIs. Add missing domain APIs.
|
||||||
|
* src/remote_internal.c: Remove hack for network APIs + test
|
||||||
|
driver now it has its own impl
|
||||||
|
* src/libvirt.c, src/driver.h, src/qemu_driver.c: Added a
|
||||||
|
'name' field to network driver
|
||||||
|
* docs/testnode.xml, docs/testnetdef.xml, docs/testnetpriv.xml:
|
||||||
|
Added example XML for network APIs
|
||||||
|
|
||||||
Thu Jul 26 10:37:31 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
Thu Jul 26 10:37:31 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/virsh.c docs/virsh.pod virsh.1: added a ttyconsole command,
|
* src/virsh.c docs/virsh.pod virsh.1: added a ttyconsole command,
|
||||||
|
12
docs/testnetdef.xml
Normal file
12
docs/testnetdef.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<network>
|
||||||
|
<name>default</name>
|
||||||
|
<uuid>004b96e12d78c30f5aa5f03c87d21e69</uuid>
|
||||||
|
<bridge name='brdefault'/>
|
||||||
|
<forward dev='eth0'/>
|
||||||
|
<ip address='192.168.122.1' netmask='255.255.255.0'>
|
||||||
|
<dhcp>
|
||||||
|
<range start='192.168.122.128' end='192.168.122.253'/>
|
||||||
|
</dhcp>
|
||||||
|
</ip>
|
||||||
|
</network>
|
||||||
|
|
11
docs/testnetpriv.xml
Normal file
11
docs/testnetpriv.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<network>
|
||||||
|
<name>private</name>
|
||||||
|
<uuid>004b22212d78c30f5aa5f03c87d21e69</uuid>
|
||||||
|
<bridge name='brpriv'/>
|
||||||
|
<ip address='192.168.124.1' netmask='255.255.255.0'>
|
||||||
|
<dhcp>
|
||||||
|
<range start='192.168.124.128' end='192.168.124.253'/>
|
||||||
|
</dhcp>
|
||||||
|
</ip>
|
||||||
|
</network>
|
||||||
|
|
@ -9,6 +9,8 @@
|
|||||||
-->
|
-->
|
||||||
<domain file="testdomfv0.xml"/>
|
<domain file="testdomfv0.xml"/>
|
||||||
<domain file="testdomfc4.xml"/>
|
<domain file="testdomfc4.xml"/>
|
||||||
|
<network file="testnetpriv.xml"/>
|
||||||
|
<network file="testnetdef.xml"/>
|
||||||
|
|
||||||
<cpu>
|
<cpu>
|
||||||
<mhz>6000</mhz>
|
<mhz>6000</mhz>
|
||||||
|
@ -304,6 +304,7 @@ typedef virNetworkDriver *virNetworkDriverPtr;
|
|||||||
* - close
|
* - close
|
||||||
*/
|
*/
|
||||||
struct _virNetworkDriver {
|
struct _virNetworkDriver {
|
||||||
|
const char * name; /* the name of the driver */
|
||||||
virDrvOpen open;
|
virDrvOpen open;
|
||||||
virDrvClose close;
|
virDrvClose close;
|
||||||
virDrvNumOfNetworks numOfNetworks;
|
virDrvNumOfNetworks numOfNetworks;
|
||||||
|
@ -423,8 +423,8 @@ do_open (const char *name, int flags)
|
|||||||
#endif
|
#endif
|
||||||
res = virDriverTab[i]->open (ret, name, flags);
|
res = virDriverTab[i]->open (ret, name, flags);
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
fprintf (stderr, "libvirt: do_open: driver %d returned %s\n",
|
fprintf (stderr, "libvirt: do_open: driver %d %s returned %s\n",
|
||||||
i,
|
i, virDriverTab[i]->name,
|
||||||
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
|
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
|
||||||
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
|
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
|
||||||
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
|
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
|
||||||
@ -444,9 +444,18 @@ do_open (const char *name, int flags)
|
|||||||
|
|
||||||
for (i = 0; i < virNetworkDriverTabCount; i++) {
|
for (i = 0; i < virNetworkDriverTabCount; i++) {
|
||||||
res = virNetworkDriverTab[i]->open (ret, name, flags);
|
res = virNetworkDriverTab[i]->open (ret, name, flags);
|
||||||
|
#ifdef ENABLE_DEBUG
|
||||||
|
fprintf (stderr, "libvirt: do_open: network driver %d %s returned %s\n",
|
||||||
|
i, virNetworkDriverTab[i]->name,
|
||||||
|
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
|
||||||
|
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
|
||||||
|
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
|
||||||
|
#endif
|
||||||
if (res == VIR_DRV_OPEN_ERROR) {
|
if (res == VIR_DRV_OPEN_ERROR) {
|
||||||
virLibConnWarning (NULL, VIR_WAR_NO_NETWORK,
|
if (STREQ(virNetworkDriverTab[i]->name, "remote")) {
|
||||||
"Is the daemon running ?");
|
virLibConnWarning (NULL, VIR_WAR_NO_NETWORK,
|
||||||
|
"Is the daemon running ?");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else if (res == VIR_DRV_OPEN_SUCCESS) {
|
} else if (res == VIR_DRV_OPEN_SUCCESS) {
|
||||||
ret->networkDriver = virNetworkDriverTab[i];
|
ret->networkDriver = virNetworkDriverTab[i];
|
||||||
|
@ -2352,6 +2352,7 @@ static virDriver qemuDriver = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static virNetworkDriver qemuNetworkDriver = {
|
static virNetworkDriver qemuNetworkDriver = {
|
||||||
|
"QEMU",
|
||||||
qemudOpenNetwork, /* open */
|
qemudOpenNetwork, /* open */
|
||||||
qemudCloseNetwork, /* close */
|
qemudCloseNetwork, /* close */
|
||||||
qemudNumNetworks, /* numOfNetworks */
|
qemudNumNetworks, /* numOfNetworks */
|
||||||
|
@ -2165,9 +2165,8 @@ remoteNetworkOpen (virConnectPtr conn,
|
|||||||
} else {
|
} else {
|
||||||
/* Using a non-remote driver, so we need to open a
|
/* Using a non-remote driver, so we need to open a
|
||||||
* new connection for network APIs, forcing it to
|
* new connection for network APIs, forcing it to
|
||||||
* use the UNIX transport. This handles Xen / Test
|
* use the UNIX transport. This handles Xen driver
|
||||||
* drivers which don't have their own impl of the
|
* which doesn't have its own impl of the network APIs.
|
||||||
* network APIs.
|
|
||||||
*/
|
*/
|
||||||
struct private_data *priv = malloc (sizeof(struct private_data));
|
struct private_data *priv = malloc (sizeof(struct private_data));
|
||||||
int ret, rflags = 0;
|
int ret, rflags = 0;
|
||||||
@ -2177,17 +2176,7 @@ remoteNetworkOpen (virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
if (flags & VIR_DRV_OPEN_RO)
|
if (flags & VIR_DRV_OPEN_RO)
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
||||||
/* Xen driver is a single system-wide driver, so
|
|
||||||
* we need the main daemon. Test driver is per
|
|
||||||
* user, so use the per-user daemon, potentially
|
|
||||||
* autostarting
|
|
||||||
*/
|
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
|
rflags |= VIR_DRV_OPEN_REMOTE_UNIX;
|
||||||
if (getuid() > 0 &&
|
|
||||||
!strcmp(conn->driver->name, "test")) {
|
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_USER;
|
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(priv, 0, sizeof(struct private_data));
|
memset(priv, 0, sizeof(struct private_data));
|
||||||
priv->magic = DEAD;
|
priv->magic = DEAD;
|
||||||
@ -2950,6 +2939,7 @@ static virDriver driver = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static virNetworkDriver network_driver = {
|
static virNetworkDriver network_driver = {
|
||||||
|
.name = "remote",
|
||||||
.open = remoteNetworkOpen,
|
.open = remoteNetworkOpen,
|
||||||
.close = remoteNetworkClose,
|
.close = remoteNetworkClose,
|
||||||
.numOfNetworks = remoteNumOfNetworks,
|
.numOfNetworks = remoteNumOfNetworks,
|
||||||
|
1916
src/test.c
1916
src/test.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user