TritonDataCenter / smartos-live

For more information, please see http://smartos.org/ For any questions that aren't answered there, please join the SmartOS discussion list: https://smartos.topicbox.com/groups/smartos-discuss
1.57k stars 245 forks source link

zonecfg exports are not importable #912

Closed dtrv closed 3 years ago

dtrv commented 4 years ago

As described on Managing Instances, zonecfg should be used to export and import zone configs. But zonecfg -z uuid export > uuid.zcfg lead to uuid.zcfg that is NOT importable by zonecfg -z uuid -f uuid.zcfg. Example to reproduce below.

From /etc/zones/uuid.xml:

...
<attr name="qemu-extra-opts" type="string" value="LXNtcCB0aHJlYWRzPTQ="/>
<attr name="alias" type="string" value="d2luZG93cw=="/>
...

(first line is qemu-extra-opts -smp threads=4 and the second line is alias windows)

leads to the following lines in uuid.zcfg:

...
add attr
set name=qemu-extra-opts
set type=string
set value=LXNtcCB0aHJlYWRzPTQ=
end
add attr
set name=alias
set type=string
set value=d2luZG93cw==
end
...

Both fail with (uuid and line number replaced) ...

syntax error on line <no> at '='
<USAGE message>
resource specification incomplete
Zone <uuid> failed to verify
<uuid>: Insufficient specification
Configuration not saved.

... because of missing quotes. Quoting the values fixes this problem and uuid.zcfg can be imported.

...
set value="LXNtcCB0aHJlYWRzPTQ="
...
set value="d2luZG93cw=="
...

I suggest to quote all base64 encoded values.

bahamat commented 3 years ago

This was fixed in joyent/illumos-joyent@c8236ea