mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Avoiding calling remote network driver recursively if inside daemon
This commit is contained in:
parent
d6f351690e
commit
8a0711c758
@ -1,3 +1,9 @@
|
||||
Fri Oct 26 21:20:44 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/libvirt.c: Don't call state driver API if callback is NULL.
|
||||
* src/remote_internal.c: Reject open attempts if inside the daemon
|
||||
to avoid recursively calling self.
|
||||
|
||||
Fri Oct 26 21:18:44 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: Support CDROM media change for KVM/QEMU
|
||||
|
@ -302,7 +302,8 @@ int __virStateInitialize(void) {
|
||||
return -1;
|
||||
|
||||
for (i = 0 ; i < virStateDriverTabCount ; i++) {
|
||||
if (virStateDriverTab[i]->initialize() < 0)
|
||||
if (virStateDriverTab[i]->initialize &&
|
||||
virStateDriverTab[i]->initialize() < 0)
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
@ -312,7 +313,8 @@ int __virStateCleanup(void) {
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0 ; i < virStateDriverTabCount ; i++) {
|
||||
if (virStateDriverTab[i]->cleanup() < 0)
|
||||
if (virStateDriverTab[i]->cleanup &&
|
||||
virStateDriverTab[i]->cleanup() < 0)
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
@ -322,7 +324,8 @@ int __virStateReload(void) {
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0 ; i < virStateDriverTabCount ; i++) {
|
||||
if (virStateDriverTab[i]->reload() < 0)
|
||||
if (virStateDriverTab[i]->reload &&
|
||||
virStateDriverTab[i]->reload() < 0)
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
@ -332,7 +335,8 @@ int __virStateActive(void) {
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0 ; i < virStateDriverTabCount ; i++) {
|
||||
if (virStateDriverTab[i]->active())
|
||||
if (virStateDriverTab[i]->active &&
|
||||
virStateDriverTab[i]->active())
|
||||
ret = 1;
|
||||
}
|
||||
return ret;
|
||||
|
@ -59,6 +59,8 @@
|
||||
#define MAGIC 999 /* private_data->magic if OK */
|
||||
#define DEAD 998 /* private_data->magic if dead/closed */
|
||||
|
||||
static int inside_daemon = 0;
|
||||
|
||||
struct private_data {
|
||||
int magic; /* Should be MAGIC or DEAD. */
|
||||
int sock; /* Socket. */
|
||||
@ -120,6 +122,16 @@ static void query_free (struct query_fields *fields);
|
||||
static int initialise_gnutls (virConnectPtr conn);
|
||||
static gnutls_session_t negotiate_gnutls_on_connection (virConnectPtr conn, int sock, int no_verify, const char *hostname);
|
||||
|
||||
static int
|
||||
remoteStartup(void)
|
||||
{
|
||||
/* Mark that we're inside the daemon so we can avoid
|
||||
* re-entering ourselves
|
||||
*/
|
||||
inside_daemon = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* remoteFindServerPath:
|
||||
*
|
||||
@ -695,9 +707,13 @@ doRemoteOpen (virConnectPtr conn, struct private_data *priv, const char *uri_str
|
||||
static int
|
||||
remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
|
||||
{
|
||||
struct private_data *priv = malloc (sizeof(struct private_data));
|
||||
struct private_data *priv;
|
||||
int ret, rflags = 0;
|
||||
|
||||
if (inside_daemon)
|
||||
return VIR_DRV_OPEN_DECLINED;
|
||||
|
||||
priv = malloc (sizeof(struct private_data));
|
||||
if (!priv) {
|
||||
error (NULL, VIR_ERR_NO_MEMORY, "struct private_data");
|
||||
return VIR_DRV_OPEN_ERROR;
|
||||
@ -2361,6 +2377,9 @@ remoteNetworkOpen (virConnectPtr conn,
|
||||
const char *uri_str,
|
||||
int flags)
|
||||
{
|
||||
if (inside_daemon)
|
||||
return VIR_DRV_OPEN_DECLINED;
|
||||
|
||||
if (conn &&
|
||||
conn->driver &&
|
||||
strcmp (conn->driver->name, "remote") == 0) {
|
||||
@ -3174,6 +3193,14 @@ static virNetworkDriver network_driver = {
|
||||
.networkSetAutostart = remoteNetworkSetAutostart,
|
||||
};
|
||||
|
||||
static virStateDriver state_driver = {
|
||||
remoteStartup,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
/** remoteRegister:
|
||||
*
|
||||
* Register driver with libvirt driver system.
|
||||
@ -3185,6 +3212,7 @@ remoteRegister (void)
|
||||
{
|
||||
if (virRegisterDriver (&driver) == -1) return -1;
|
||||
if (virRegisterNetworkDriver (&network_driver) == -1) return -1;
|
||||
if (virRegisterStateDriver (&state_driver) == -1) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user