Skip to content

possible bug/error when using API with unix sockets #7449

@achenet

Description

@achenet

Hello,

Sorry if this is a basic question, but I think I may be having trouble following the basic example in the docs/api.md documentation.

The example in the doc:
https://github.com/cloud-hypervisor/cloud-hypervisor/blob/main/docs/api.md#rest-api-examples

seem to say, if I understand it correctly, that once the cloud-hypervisor binary is built locally, running the program with the flag --api-socket /tmp/cloud-hypervisor.sock should output

Cloud Hypervisor Guest
    API server: /tmp/cloud-hypervisor.sock
    vCPUs: 1
    Memory: 512 MB
    Kernel: None
    Kernel cmdline:
    Disk(s): None

however, when I run the command to execute the binary with the required flag

./target/debug/cloud-hypervisor --api-socket /tmp/cloud-hypervisor.sock

I get no output in my terminal, just a line return but no prompt being printed to signal that the program is executing.

Furthermore, when I try the next part of the example

#!/usr/bin/env bash

curl --unix-socket /tmp/cloud-hypervisor.sock -i \
     -X PUT 'http://localhost/api/v1/vm.create'  \
     -H 'Accept: application/json'               \
     -H 'Content-Type: application/json'         \
     -d '{
         "cpus":{"boot_vcpus": 4, "max_vcpus": 4},
         "payload":{"kernel":"/opt/clh/kernel/vmlinux-virtio-fs-virtio-iommu", "cmdline":"console=ttyS0 console=hvc0 root=/dev/vda1 rw"},
         "disks":[{"path":"/opt/clh/images/focal-server-cloudimg-amd64.raw"}],
         "rng":{"src":"/dev/urandom"},
         "net":[{"ip":"192.168.10.10", "mask":"255.255.255.0", "mac":"12:34:56:78:90:01"}]
         }'

curl outputs

curl: (52) Empty reply from server

and the program crashes with SIGSYS


==== Possible seccomp violation ====
                                    Try running with `strace -ff` to identify the cause and open an issue: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/new
                                         fish: Job 1, './target/debug/cloud-hypervisor…' terminated by signal SIGSYS (Bad system call)

I am running the program on a ThinkPad T490 with Debian 12.8 Bookworm distribution, Linux kernel 6.1.0-28-amd64.

Following the program error message, I tried strace -ff ./target/debug/cloud-hypervisor --api-socket /tmp/cloud-hypervisor.sock and got a long output, which I've put in an attached file because it seem too big to paste into the Github issue box.

strace-api-unix-socket.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions