Skip to content

Commit 2263743

Browse files
stgrabermihalicyn
authored andcommitted
lxd/instance/drivers/qemu: Limit CPU flag calculation to x86_64
The "kvm64" CPU definition doesn't exist on aarch64 and possibly on other platforms, so restrict the logic to x86_64 for the time being. Signed-off-by: Stéphane Graber <[email protected]> (cherry picked from commit ee24c49a275268f08f9dd060fba1256699fee65e) Signed-off-by: Kadin Sayani <[email protected]> Signed-off-by: Gabriel Mougard <[email protected]> License: Apache-2.0
1 parent 9939ccd commit 2263743

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lxd/instance/drivers/driver_qemu.go

+18-16
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ func (d *qemu) getClusterCPUFlags() ([]string, error) {
410410

411411
for _, node := range nodes {
412412
// Attempt to load the cached resources.
413-
resourcesPath := internalUtil.CachePath("resources", fmt.Sprintf("%s.yaml", node.Name))
413+
resourcesPath := shared.CachePath("resources", fmt.Sprintf("%s.yaml", node.Name))
414414

415415
data, err := os.ReadFile(resourcesPath)
416416
if err != nil {
@@ -1574,8 +1574,8 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
15741574

15751575
cpuType := "host"
15761576

1577-
// Get CPU flags if clustered and migration is enabled.
1578-
if d.state.ServerClustered && util.IsTrue(d.expandedConfig["migration.stateful"]) {
1577+
// Get CPU flags if clustered and migration is enabled (x86_64 only for now).
1578+
if d.architecture == osarch.ARCH_64BIT_INTEL_X86 && d.state.ServerClustered && shared.IsTrue(d.expandedConfig["migration.stateful"]) {
15791579
cpuFlags, err := d.getClusterCPUFlags()
15801580
if err != nil {
15811581
op.Done(err)
@@ -9035,24 +9035,26 @@ func (d *qemu) checkFeatures(hostArch int, qemuPath string) (map[string]any, err
90359035
features["vhost_net"] = struct{}{}
90369036
}
90379037

9038-
// Get the host CPU model.
9039-
model, err := monitor.QueryCPUModel("kvm64")
9040-
if err != nil {
9041-
return nil, err
9042-
}
9038+
// Get the host CPU model (x86_64 only for now).
9039+
if hostArch == osarch.ARCH_64BIT_INTEL_X86 {
9040+
model, err := monitor.QueryCPUModel("kvm64")
9041+
if err != nil {
9042+
return nil, err
9043+
}
90439044

9044-
cpuFlags := map[string]bool{}
9045-
for k, v := range model.Flags {
9046-
value, ok := v.(bool)
9047-
if !ok {
9048-
continue
9045+
cpuFlags := map[string]bool{}
9046+
for k, v := range model.Flags {
9047+
value, ok := v.(bool)
9048+
if !ok {
9049+
continue
9050+
}
9051+
9052+
cpuFlags[k] = value
90499053
}
90509054

9051-
cpuFlags[k] = value
9055+
features["flags"] = cpuFlags
90529056
}
90539057

9054-
features["flags"] = cpuFlags
9055-
90569058
return features, nil
90579059
}
90589060

0 commit comments

Comments
 (0)