Bug 2042809

Summary: sysprep disk requires autounattend.xml if an unattend.xml exists
Product: Container Native Virtualization (CNV) Reporter: Dominik Holler <dholler>
Component: SSPAssignee: Lee Yarwood <lyarwood>
Status: CLOSED ERRATA QA Contact: Roni Kishner <rkishner>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.9.4CC: cnv-qe-bugs, rkishner, rnetser, ycui
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-14 19:28:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dominik Holler 2022-01-20 07:59:15 UTC
Description of problem:
Even if an unattend.xml file is requested for the sysprep disk, cnv requires the file autounattend.xml to exist.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Create VM with sysprep disk containing unattend.xml, but not autounattend.xml


Actual results:
VM fails to boot


Expected results:
VM boots if at least unattend.xml or autounattend.xml exists.

Additional info:

Comment 1 Dominik Holler 2022-01-20 08:00:40 UTC
The workaround is to create an empty autounattend.xml.

Comment 2 Lee Yarwood 2022-02-10 18:21:29 UTC
I can reproduce this with the following:

$ oc get -n kubevirt-hyperconverged vms lyarwood-windows10-nasty-donkey -o json | jq '.spec.template.spec.volumes'
[
  {
    "dataVolume": {
      "name": "lyarwood-windows10-nasty-donkey-rootdisk-zz9rz"
    },
    "name": "rootdisk"
  },
  {
    "name": "sysprep",
    "sysprep": {
      "configMap": {
        "name": "sysprep-config-lyarwood-windows10-nasty-donkey"
      }
    }
  }
]

$ oc get -n kubevirt-hyperconverged configmap sysprep-config-lyarwood-windows10-nasty-donkey -o json | jq -r .data | sed 's/\\n/\n/g'
{
  "Unattend.xml": "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<unattend xmlns=\"urn:schemas-microsoft-com:unattend\">
  <settings pass=\"oobeSystem\">
    <component xmlns:wcm=\"http://schemas.microsoft.com/WMIConfig/2002/State\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"Microsoft-Windows-Shell-Setup\" processorArchitecture=\"amd64\" publicKeyToken=\"31bf3856ad364e35\" language=\"neutral\" versionScope=\"nonSxS\">
      <OOBE>
        <HideEULAPage>true</HideEULAPage>
        <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
        <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
        <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
        <NetworkLocation>Work</NetworkLocation>
        <SkipUserOOBE>true</SkipUserOOBE>
        <SkipMachineOOBE>true</SkipMachineOOBE>
        <ProtectYourPC>3</ProtectYourPC>
      </OOBE>
      <AutoLogon>
        <Password>
        <Value>123456</Value>
          <PlainText>true</PlainText>
        </Password>
        <Enabled>true</Enabled>
    <Username>Administrator</Username>
</AutoLogon>
<UserAccounts>
     <AdministratorPassword>
            <Value>123456</Value>
            <PlainText>true</PlainText>
    </AdministratorPassword>
      </UserAccounts>
      <RegisteredOrganization/>
      <RegisteredOwner/>
      <TimeZone>Eastern Standard Time</TimeZone>
    </component>
  </settings>
</unattend>"
}

$ oc logs -n kubevirt-hyperconverged virt-launcher-lyarwood-windows10-nasty-donkey-rvhxl | tail -n1 | jq .
{
  "component": "virt-launcher",
  "kind": "",
  "level": "error",
  "msg": "Failed to sync vmi",
  "name": "lyarwood-windows10-nasty-donkey",
  "namespace": "kubevirt-hyperconverged",
  "pos": "server.go:184",
  "reason": "creating sysprep disks failed: Sysprep drive should contain autounattend.xml, but it was not found",
  "timestamp": "2022-02-10T17:00:11.354899Z",
  "uid": "be21af5c-4ade-4513-bf15-031c4d3ebe43"
}

The failure is coming from the following code checking for autounattend.xml:

https://github.com/kubevirt/kubevirt/blob/8a07d2dc92fb0908455b833a1fbcb6ffdb965570/pkg/config/sysprep.go#L49-L64

I'll change this to check for either and test to ensure that if only unattend.xml is provided that it sysprep actually works. Reading the docs suggests that only autounattend.xml is picked up from removable media etc:

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-automation-overview?view=windows-11#implicit-answer-file-search-order

Comment 3 Roni Kishner 2022-04-05 18:46:18 UTC
Verified on ssp-operator v4.11.0-16

Comment 6 errata-xmlrpc 2022-09-14 19:28:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Virtualization 4.11.0 Images security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:6526