mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +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>
|
||||
|
||||
* 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="testdomfc4.xml"/>
|
||||
<network file="testnetpriv.xml"/>
|
||||
<network file="testnetdef.xml"/>
|
||||
|
||||
<cpu>
|
||||
<mhz>6000</mhz>
|
||||
|
@ -304,6 +304,7 @@ typedef virNetworkDriver *virNetworkDriverPtr;
|
||||
* - close
|
||||
*/
|
||||
struct _virNetworkDriver {
|
||||
const char * name; /* the name of the driver */
|
||||
virDrvOpen open;
|
||||
virDrvClose close;
|
||||
virDrvNumOfNetworks numOfNetworks;
|
||||
|
@ -423,8 +423,8 @@ do_open (const char *name, int flags)
|
||||
#endif
|
||||
res = virDriverTab[i]->open (ret, name, flags);
|
||||
#ifdef ENABLE_DEBUG
|
||||
fprintf (stderr, "libvirt: do_open: driver %d returned %s\n",
|
||||
i,
|
||||
fprintf (stderr, "libvirt: do_open: driver %d %s returned %s\n",
|
||||
i, virDriverTab[i]->name,
|
||||
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
|
||||
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
|
||||
(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++) {
|
||||
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) {
|
||||
virLibConnWarning (NULL, VIR_WAR_NO_NETWORK,
|
||||
"Is the daemon running ?");
|
||||
if (STREQ(virNetworkDriverTab[i]->name, "remote")) {
|
||||
virLibConnWarning (NULL, VIR_WAR_NO_NETWORK,
|
||||
"Is the daemon running ?");
|
||||
}
|
||||
break;
|
||||
} else if (res == VIR_DRV_OPEN_SUCCESS) {
|
||||
ret->networkDriver = virNetworkDriverTab[i];
|
||||
|
@ -2352,6 +2352,7 @@ static virDriver qemuDriver = {
|
||||
};
|
||||
|
||||
static virNetworkDriver qemuNetworkDriver = {
|
||||
"QEMU",
|
||||
qemudOpenNetwork, /* open */
|
||||
qemudCloseNetwork, /* close */
|
||||
qemudNumNetworks, /* numOfNetworks */
|
||||
|
@ -2165,9 +2165,8 @@ remoteNetworkOpen (virConnectPtr conn,
|
||||
} else {
|
||||
/* Using a non-remote driver, so we need to open a
|
||||
* new connection for network APIs, forcing it to
|
||||
* use the UNIX transport. This handles Xen / Test
|
||||
* drivers which don't have their own impl of the
|
||||
* network APIs.
|
||||
* use the UNIX transport. This handles Xen driver
|
||||
* which doesn't have its own impl of the network APIs.
|
||||
*/
|
||||
struct private_data *priv = malloc (sizeof(struct private_data));
|
||||
int ret, rflags = 0;
|
||||
@ -2177,17 +2176,7 @@ remoteNetworkOpen (virConnectPtr conn,
|
||||
}
|
||||
if (flags & VIR_DRV_OPEN_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;
|
||||
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));
|
||||
priv->magic = DEAD;
|
||||
@ -2950,6 +2939,7 @@ static virDriver driver = {
|
||||
};
|
||||
|
||||
static virNetworkDriver network_driver = {
|
||||
.name = "remote",
|
||||
.open = remoteNetworkOpen,
|
||||
.close = remoteNetworkClose,
|
||||
.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