Fix segfault when starting a domain with no cpu definition

My commit fba6bc4 iterated over the features in cpu definition
without checking if there is one.
This commit is contained in:
Ján Tomko 2014-07-02 10:35:31 +02:00
parent d950494129
commit 1cd8f500ee
2 changed files with 2 additions and 2 deletions

View File

@ -1513,7 +1513,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
return false; return false;
} }
for (i = 0; i < def->cpu->nfeatures; i++) { for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
virCPUFeatureDefPtr feature = &def->cpu->features[i]; virCPUFeatureDefPtr feature = &def->cpu->features[i];
if (feature->policy != VIR_CPU_FEATURE_REQUIRE) if (feature->policy != VIR_CPU_FEATURE_REQUIRE)

View File

@ -3636,7 +3636,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
} }
} }
for (i = 0; i < def->cpu->nfeatures; i++) { for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
virCPUFeatureDefPtr feature = &def->cpu->features[i]; virCPUFeatureDefPtr feature = &def->cpu->features[i];
if (feature->policy != VIR_CPU_FEATURE_REQUIRE) if (feature->policy != VIR_CPU_FEATURE_REQUIRE)