]> xenbits.xensource.com Git - libvirt.git/commitdiff
test_driver: implement virDomainSendProcessSignal
authorIlias Stamatis <stamatis.iliass@gmail.com>
Tue, 4 Jun 2019 13:17:43 +0000 (15:17 +0200)
committerErik Skultety <eskultet@redhat.com>
Wed, 19 Jun 2019 13:13:39 +0000 (15:13 +0200)
Only succeed when @pid_value is 1, since according to the docs this is
the minimum requirement for any driver to implement this API.
Since this is test driver, we assume that any signal from the supported
list can be sent to pid 1 and we therefore succeed every time.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/test/test_driver.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8ef843b..b95aaf4
@@ -2954,6 +2954,40 @@ static int testDomainSetMetadata(virDomainPtr dom,
     return ret;
 }
 
+static int
+testDomainSendProcessSignal(virDomainPtr dom,
+                            long long pid_value,
+                            unsigned int signum,
+                            unsigned int flags)
+{
+    int ret = -1;
+    virDomainObjPtr vm = NULL;
+
+    virCheckFlags(0, -1);
+
+    if (pid_value != 1) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("only sending a signal to pid 1 is supported"));
+        return -1;
+    }
+
+    if (signum >= VIR_DOMAIN_PROCESS_SIGNAL_LAST) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("signum value %d is out of range"),
+                       signum);
+        return -1;
+    }
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        goto cleanup;
+
+    /* do nothing */
+    ret = 0;
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
 
 static int testNodeGetCellsFreeMemory(virConnectPtr conn,
                                       unsigned long long *freemems,
@@ -7199,6 +7233,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainSendKey = testDomainSendKey, /* 5.5.0 */
     .domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
     .domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
+    .domainSendProcessSignal = testDomainSendProcessSignal, /* 5.5.0 */
     .connectGetCPUModelNames = testConnectGetCPUModelNames, /* 1.1.3 */
     .domainManagedSave = testDomainManagedSave, /* 1.1.4 */
     .domainHasManagedSaveImage = testDomainHasManagedSaveImage, /* 1.1.4 */