Re: [PATCH 1/4] Add virDomainSendProcessSignal API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/28/12 12:31, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Add an API for sending signals to arbitrary processes in the
guest OS. This is primarily useful for container based virt,
but can be used for machine virt too, if there is a suitable
guest agent,

* include/libvirt/libvirt.h.in: Add virDomainSendProcessSignal
   and virDomainProcessSignal enum
* src/driver.h: Driver entry point
* src/libvirt.c, src/libvirt_public.syms: Impl for new API
---
  include/libvirt/libvirt.h.in | 60 ++++++++++++++++++++++++++++++++++++
  src/driver.h                 |  7 +++++
  src/libvirt.c                | 72 ++++++++++++++++++++++++++++++++++++++++++++
  src/libvirt_public.syms      |  5 +++
  4 files changed, 144 insertions(+)


diff --git a/src/libvirt.c b/src/libvirt.c
index 4af6089..83550cd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -8589,6 +8589,78 @@ error:
      return -1;
  }

+
+/**
+ * virDomainSendProcessSignal:
+ * @domain: pointer to domain object
+ * @pid_value: a positive integer process ID greater than zero
+ * @signum: a signal from the virDomainProcessSignal enum
+ * @flags: one of the virDomainProcessSignalFlag values
+ *
+ * Send a signal to the designated process in the guest
+ *
+ * The signal numbers must be taken from the virDomainProcessSignal
+ * enum. These will be translated to the corresponding signal
+ * number for the guest OS, by the guest agent delivering the
+ * signal.
+ *
+ * The @pid_value must specify a process ID greater than zero. The
+ * @pid_value numbers are from the container/guest namespace.
+ *
+ * If the @signum is VIR_DOMAIN_PROCESS_SIGNAL_NOP then this
+ * API will simply report whether the process is running in
+ * the container/guest

s/guest/guest./

+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int virDomainSendProcessSignal(virDomainPtr domain,
+                               unsigned int pid_value,
+                               unsigned int signum,
+                               unsigned int flags)
+{
+    virConnectPtr conn;
+    VIR_DOMAIN_DEBUG(domain, "pid=%u, signum=%u flags=%x",
+                     pid_value, signum, flags);
+
+    virResetLastError();
+
+    if (pid_value == 0) {

Use virCheckNonZeroArgGoto here.

+        virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }

ACK to the code. As this is a API change, please wait a day or two for other possible comments to the semantic of this API.

Peter

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]