[libvirt] [PATCH] daemon: Unlink unix socket paths on shutdown
by Osier Yang
This patch introduces a internal RPC API "virNetServerClose", which
is standalone with "virNetServerFree". it closes all the socket fds,
and unlinks the unix socket paths, regardless of whether the socket
is still referenced or not.
This is to address regression bug:
https://bugzilla.redhat.com/show_bug.cgi?id=725702
---
daemon/libvirtd.c | 1 +
src/rpc/virnetserver.c | 12 ++++++++++++
src/rpc/virnetserver.h | 1 +
src/rpc/virnetserverservice.c | 12 ++++++…
[View More]++++++
src/rpc/virnetserverservice.h | 2 ++
src/rpc/virnetsocket.c | 16 ++++++++++++++++
src/rpc/virnetsocket.h | 2 ++
7 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 9e044e2..53f1002 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1558,6 +1558,7 @@ int main(int argc, char **argv) {
cleanup:
virNetServerProgramFree(remoteProgram);
virNetServerProgramFree(qemuProgram);
+ virNetServerClose(srv);
virNetServerFree(srv);
if (statuswrite != -1) {
if (ret != 0) {
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 2dae2ff..d2a6fef 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -794,3 +794,15 @@ void virNetServerFree(virNetServerPtr srv)
virMutexDestroy(&srv->lock);
VIR_FREE(srv);
}
+
+void virNetServerClose(virNetServerPtr srv)
+{
+ int i;
+
+ if (!srv)
+ return;
+
+ for (i = 0; i < srv->nservices; i++) {
+ virNetServerServiceClose(srv->services[i]);
+ }
+}
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 810d8a3..324cfb7 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -85,5 +85,6 @@ void virNetServerQuit(virNetServerPtr srv);
void virNetServerFree(virNetServerPtr srv);
+void virNetServerClose(virNetServerPtr srv);
#endif
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index d5648dc..8c9ed1e 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -280,3 +280,15 @@ void virNetServerServiceToggle(virNetServerServicePtr svc,
VIR_EVENT_HANDLE_READABLE :
0);
}
+
+void virNetServerServiceClose(virNetServerServicePtr svc)
+{
+ int i;
+
+ if (!svc)
+ return;
+
+ for (i = 0; i < svc->nsocks; i++) {
+ virNetSocketClose(svc->socks[i]);
+ }
+}
diff --git a/src/rpc/virnetserverservice.h b/src/rpc/virnetserverservice.h
index 9357598..8540bd9 100644
--- a/src/rpc/virnetserverservice.h
+++ b/src/rpc/virnetserverservice.h
@@ -66,4 +66,6 @@ void virNetServerServiceFree(virNetServerServicePtr svc);
void virNetServerServiceToggle(virNetServerServicePtr svc,
bool enabled);
+void virNetServerServiceClose(virNetServerServicePtr svc);
+
#endif
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 41b691a..b94b629 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1222,3 +1222,19 @@ void virNetSocketRemoveIOCallback(virNetSocketPtr sock)
virMutexUnlock(&sock->lock);
}
+
+void virNetSocketClose(virNetSocketPtr sock)
+{
+ if (!sock)
+ return;
+
+ VIR_FORCE_CLOSE(sock->fd);
+
+#ifdef HAVE_SYS_UN_H
+ /* If a server socket, then unlink UNIX path */
+ if (!sock->client &&
+ sock->localAddr.data.sa.sa_family == AF_UNIX &&
+ sock->localAddr.data.un.sun_path[0] != '\0')
+ unlink(sock->localAddr.data.un.sun_path);
+#endif
+}
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index dfb3c5d..3735a88 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -118,6 +118,8 @@ void virNetSocketUpdateIOCallback(virNetSocketPtr sock,
void virNetSocketRemoveIOCallback(virNetSocketPtr sock);
+void virNetSocketClose(virNetSocketPtr sock);
+
#endif /* __VIR_NET_SOCKET_H__ */
--
1.7.6
[View Less]
13 years, 8 months
[libvirt] [PATCH v2] qemu: fix return value issue
by ajia@redhat.com
whether or not previous return value is -1, the following codes will be
executed for a inactive guest in src/qemu/qemu_driver.c:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
in out of blkio weight range for a inactive guest.
* how to reproduce?
% virsh blkiotune ${…
[View More]guestname} --weight 10
% echo $?
Note: guest must be inactive, argument 10 in out of blkio weight range,
and can get a error information by checking libvirtd.log, however,
virsh hasn't raised any error information, and return value is 0.
https://bugzilla.redhat.com/show_bug.cgi?id=726304
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b673fd5..aaccddf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5688,7 +5688,9 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
ret = -1;
}
}
- ret = virDomainSaveConfig(driver->configDir, persistentDef);
+
+ if (virDomainSaveConfig(driver->configDir, persistentDef) < 0)
+ ret = -1;
}
cleanup:
--
1.7.1
[View Less]
13 years, 8 months
[libvirt] [PATCH v2] qemu: fix return value issue in qemuDomainSetMemoryParameters
by ajia@redhat.com
whether or not previous return value is -1, the following codes will be
executed for a inactive guest in qemuDomainSetMemoryParameters:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when set
min_guarante value to a inactive guest.
* how to reproduce?
% virsh memtune ${guestname} --…
[View More]min_guarante 1024
% echo $?
Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
in memory tunable, and I can get the error when check actual libvirtd.log,
however, virsh hasn't raised any error information, and return value is 0.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cce1c68..cb5108d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5983,7 +5983,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- ret = virDomainSaveConfig(driver->configDir, persistentDef);
+ if(virDomainSaveConfig(driver->configDir, persistentDef) < 0)
+ ret = -1;
}
cleanup:
--
1.7.1
[View Less]
13 years, 8 months
[libvirt] [PATCH] qemu: fix return value issue
by ajia@redhat.com
whether or not previous return value is -1, the following codes will be
executed for a inactive guest in src/qemu/qemu_driver.c:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
in out of blkio weight range for a inactive guest.
* how to reproduce?
% virsh blkiotune ${…
[View More]guestname} --weight 10
% echo $?
Note: guest must be inactive, argument 10 in out of blkio weight range,
however, virsh hasn't raised any error information, and return value is 0.
https://bugzilla.redhat.com/show_bug.cgi?id=726304
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b673fd5..aaccddf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5688,7 +5688,9 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
ret = -1;
}
}
- ret = virDomainSaveConfig(driver->configDir, persistentDef);
+
+ if(virDomainSaveConfig(driver->configDir, persistentDef) < 0)
+ goto cleanup;
}
cleanup:
--
1.7.1
[View Less]
13 years, 8 months
[libvirt] [PATCH] virsh: Fix vol-name and vol-pool commands
by Matthias Bolte
This commands don't have a --pool option, so don't tell
vshCommandOptVolBy that there could be one. This made
vshCommandOptString for pooloptname fail and an "missing option"
error was reported.
Make pooloptname optional for vshCommandOptVolBy.
---
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 9e0744d..5fcf370 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9201,7 +9201,7 @@ cmdVolName(vshControl *ctl, const …
[View More]vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
- if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
+ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
VSH_BYUUID)))
return false;
@@ -9238,7 +9238,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
return false;
/* Use the supplied string to locate the volume */
- if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
+ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
VSH_BYUUID))) {
return false;
}
@@ -13619,7 +13619,7 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
if (vshCommandOptString(cmd, optname, &n) <= 0)
return NULL;
- if (vshCommandOptString(cmd, pooloptname, &p) < 0) {
+ if (pooloptname != NULL && vshCommandOptString(cmd, pooloptname, &p) < 0) {
vshError(ctl, "%s", _("missing option"));
return NULL;
}
--
1.7.4.1
[View Less]
13 years, 8 months
[libvirt] [PATCH] Correct the default value of lock_manager in qemu.conf
by Guannan Ren
* src/qemu/qemu.conf lock_manager = "sanlock"
---
src/qemu/qemu.conf | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 8058352..79c6e85 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -304,9 +304,8 @@
#
# max_processes = 0
-# To enable strict 'fcntl' based locking of the file
+# To enable 'Sanlock' project based locking of the file
# content (to prevent two VMs writing to the same
-# disk), start the '…
[View More]virtlockd' service, and uncomment
-# this
+# disk), uncomment this
#
-# lock_manager = "fcntl"
+# lock_manager = "sanlock"
--
1.7.1
[View Less]
13 years, 8 months
[libvirt] [PATCH] qemu: Fix a regression of domjobabort
by Osier Yang
Introduced by f9a837da73a11ef, the condition is not changed after
the else clause is removed. So now it quit with "domain is not
running" when the domain is running. However, when the domain is
not running, it reports "no job is active".
How to reproduce:
1)
% virsh start $domain
% virsh domjobabort $domain
error: Requested operation is not valid: domain is not running
2)
% virsh destroy $domain
% virsh domjobabort $domain
error: Requested operation is not valid: no job is active on the …
[View More]domain
3)
% virsh save $domain /tmp/$domain.save
Before above commands finished, try to abort job in another terminal
% virsh domabortjob $domain
error: Requested operation is not valid: domain is not running
---
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b673fd5..cce1c68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8065,7 +8065,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) {
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_ABORT) < 0)
goto cleanup;
- if (virDomainObjIsActive(vm)) {
+ if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
--
1.7.6
[View Less]
13 years, 8 months
[libvirt] [PATCH] qemu: fix return value issue in qemuDomainSetMemoryParameters
by ajia@redhat.com
whether or not previous return value is -1, the following codes will be
executed for a inactive guest in qemuDomainSetMemoryParameters:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when set
min_guarante value to a inactive guest.
* how to reproduce?
% virsh memtune ${guestname} --…
[View More]min_guarante 1024
% echo $?
Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
in memory tunable, and I can get the error when check actual libvirtd.log,
however, virsh hasn't raised any error information, and return value is 0.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b673fd5..a099723 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5983,7 +5983,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- ret = virDomainSaveConfig(driver->configDir, persistentDef);
+ if(virDomainSaveConfig(driver->configDir, persistentDef) < 0)
+ goto cleanup;
}
cleanup:
--
1.7.1
[View Less]
13 years, 8 months
[libvirt] [PATCH] conf: Don't leak the virtual port profile in virNetworkDefFree
by Matthias Bolte
Reported by Alex Jia.
---
src/conf/network_conf.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 6714c20..b11c482 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -169,6 +169,8 @@ void virNetworkDefFree(virNetworkDefPtr def)
virNetworkDNSDefFree(def->dns);
+ VIR_FREE(def->virtPortProfile);
+
virBandwidthDefFree(def->bandwidth);
VIR_FREE(def);
--
1.7.4.1
13 years, 8 months