Skip to content

Commit

Permalink
Merge pull request #1185 from stgraber/main
Browse files Browse the repository at this point in the history
Various bugfixes
  • Loading branch information
hallyn authored Sep 5, 2024
2 parents 7f0bdd0 + c3926c9 commit 927b75e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
16 changes: 10 additions & 6 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
if cpuInfo.vcpus == nil {
if d.architectureSupportsCPUHotplug() && cpuInfo.cores > 1 {
// Hotplug the CPUs.
err := d.setCPUs(cpuInfo.cores)
err := d.setCPUs(monitor, cpuInfo.cores)
if err != nil {
err = fmt.Errorf("Failed to add CPUs: %w", err)
op.Done(err)
Expand Down Expand Up @@ -5785,7 +5785,7 @@ func (d *qemu) Update(args db.InstanceArgs, userRequested bool) error {
}

// Hotplug the CPUs.
err = d.setCPUs(limit)
err = d.setCPUs(nil, limit)
if err != nil {
return fmt.Errorf("Failed updating cpu limit: %w", err)
}
Expand Down Expand Up @@ -9090,15 +9090,19 @@ func (d *qemu) blockNodeName(name string) string {
return fmt.Sprintf("%s%s", qemuBlockDevIDPrefix, name)
}

func (d *qemu) setCPUs(count int) error {
func (d *qemu) setCPUs(monitor *qmp.Monitor, count int) error {
if count == 0 {
return nil
}

// Check if the agent is running.
monitor, err := qmp.Connect(d.monitorPath(), qemuSerialChardevName, d.getMonitorEventHandler())
if err != nil {
return err
if monitor == nil {
var err error

monitor, err = qmp.Connect(d.monitorPath(), qemuSerialChardevName, d.getMonitorEventHandler())
if err != nil {
return err
}
}

cpus, err := monitor.QueryHotpluggableCPUs()
Expand Down
4 changes: 4 additions & 0 deletions internal/server/instance/drivers/qmp/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func (m *Monitor) RunJSON(request []byte, resp any) error {

// Decode the response if needed.
if resp != nil {
// Handle weird QEMU QMP bug.
responses := strings.Split(string(out), "\r\n")
out = []byte(responses[len(responses)-1])

err = json.Unmarshal(out, &resp)
if err != nil {
// Confirm the daemon didn't die.
Expand Down
6 changes: 3 additions & 3 deletions internal/server/seccomp/seccomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static const struct incus_seccomp_data_arch seccomp_notify_syscall_table[] = {
{ AUDIT_ARCH_I386, 14, 297, 226, 21, 357, 156, 116 },
#endif
#ifdef AUDIT_ARCH_AARCH64
{ AUDIT_ARCH_AARCH64, -1, 33, 5, 21, 386, 156, 179 },
{ AUDIT_ARCH_AARCH64, -1, 33, 5, 40, 280, 119, 179 },
#endif
#ifdef AUDIT_ARCH_ARM
{ AUDIT_ARCH_ARM, 14, 324, 226, 21, 386, 156, 116 },
Expand All @@ -128,7 +128,7 @@ static const struct incus_seccomp_data_arch seccomp_notify_syscall_table[] = {
{ AUDIT_ARCH_ARMEB, 14, 324, 226, 21, 386, 156, 116 },
#endif
#ifdef AUDIT_ARCH_S390
{ AUDIT_ARCH_S390, 14, 290, 224, 21, 386, 156, 116 },
{ AUDIT_ARCH_S390, 14, 290, 224, 21, 351, 156, 116 },
#endif
#ifdef AUDIT_ARCH_S390X
{ AUDIT_ARCH_S390X, 14, 290, 224, 21, 351, 156, 116 },
Expand All @@ -143,7 +143,7 @@ static const struct incus_seccomp_data_arch seccomp_notify_syscall_table[] = {
{ AUDIT_ARCH_PPC64LE, 14, 288, 209, 21, 361, 156, 116 },
#endif
#ifdef AUDIT_ARCH_RISCV64
{ AUDIT_ARCH_RISCV64, -1, 33, 5, 40, 280, -1, 179 },
{ AUDIT_ARCH_RISCV64, -1, 33, 5, 40, 280, 119, 179 },
#endif
#ifdef AUDIT_ARCH_SPARC
{ AUDIT_ARCH_SPARC, 14, 286, 169, 167, 349, 243, 214 },
Expand Down

0 comments on commit 927b75e

Please sign in to comment.